Skip to content

Fixes #18#2549

Merged
Dunbaratu merged 1 commit intoKSP-KOS:developfrom
Dunbaratu:ternary_operator
Jun 22, 2019
Merged

Fixes #18#2549
Dunbaratu merged 1 commit intoKSP-KOS:developfrom
Dunbaratu:ternary_operator

Conversation

@Dunbaratu
Copy link
Member

This has been sitting a long time, but was stuck on not
liking any syntax choice - then it came up in Discord
again and people seemed to like this, so I finally did
it:

CHOOSE expr1 IF bool_expr ELSE expr2.

 This has been sitting a long time, but was stuck on not
 liking any syntax choice - then it came up in Discord
 again and people seemed to like this, so I finally did
 it:

    CHOOSE expr1 IF bool_expr ELSE expr2.
@Dunbaratu Dunbaratu added the enhancement Something new (not a bug fix) is being requested label Jun 15, 2019
print " Next 2 lines should be 'B':".
print " " + (choose "A" if (choose x if a=2 else y) else "B").
print " " + (choose "A" if choose x if a=2 else y else "B"). // same without parens should work.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
+
+print "Third nesting case - nesting choose in the first term.".
+print " Next two lines should be 'A'.".
+print " " + (choose (choose "A" if true else "B") if true else "C").
+print " " + (choose choose "A" if true else "B" if true else "C"). // same without parens should work.
+print " Next two lines should be 'B'.".
+print " " + (choose (choose "A" if false else "B") if true else "C").
+print " " + (choose choose "A" if false else "B" if true else "C"). // same without parens should work.
+print " Next four lines should be 'C'.".
+print " " + (choose (choose "A" if true else "B") if false else "C").
+print " " + (choose choose "A" if true else "B" if false else "C"). // same without parens should work.
+print " " + (choose (choose "A" if false else "B") if false else "C"). // result of inner test should affect result
+print " " + (choose choose "A" if false else "B" if false else "C"). // same without parens should work.
+
+

@Dunbaratu Dunbaratu merged commit b9b1bd5 into KSP-KOS:develop Jun 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Something new (not a bug fix) is being requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants