RE: Ternaries

2 views
Skip to first unread message

Scott Hofmann

unread,
Jun 13, 2013, 9:45:22 AM6/13/13
to cincin...@googlegroups.com

Scott wrote:

So I would expect it to be written like this:

                5 < 6 ? puts "five is less than six !" : puts "six is not less than five."

 

Anyone care to comment on why my logic is failed? ...other than it does not work that way J

 

Michael Guterl wrote:

Your expected example does not work due to a parse error. In this case you need the parenthesis:

5 < 6 ? puts("five is less than six !") : puts("six is not less than five.")

 

Nice to see that ternary is doable with parenthesis. But now that leads me to question a simple puts statement. How come I’m not “required” for this puts =>  puts(“some string”) instead of puts “some string”. I would say this puts “some string” is not ambiguous so parenthesis should not be required, which they are not. But I think the same would be true in a ternary. Where does the ambiguity come in a ternary forcing the need for parenthesis?

 

subject line changed…plural of ternary is ternaries, sorry about that. - Scott

 

 

Reply all
Reply to author
Forward
0 new messages