Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Ruby
Ternary Usage
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Greg Willits, post: 4578831"] New to Ruby. Having trouble with ternary statements. I am used to a language that allows these two forms: test ? trueStuff test ? trueStuff | falseStuff While I have yet to find a reference that explicitly states this, it would appear that ternary statement in Ruby is not allowed to exclude the :, as without it I get an "unexpected '\n'" error statement. Ok, fine, so I can write something like this: $debug ? $devLog.info("bla bla bla") : That's working for most cases, however, whenever such a line appears in IF statements, it generates another set of errors. if (...whatever...) ...do some stuff... $debug ? $devLog.info("bla bla bla") : else ...do other stuff... $debug ? $devLog.info("yadda yadda") : end I get "unexpected kELSE" and "unexpected kEND" syntax errors. Hard to comprehend what can be so tricky about a simple ternary statement. Indeed it is assumed to be so simple that the Programming Ruby book offers no details for its use, yet clearly there are some rules that need to be followed. Any enlightment is appreciated. TIA. -- greg willits [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Ruby
Ternary Usage
Top