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 operator request
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="Alex Fenton, post: 4483380"] That's a cute idea. I do find myself writing code like something.zero? ? x : y But presently there's nothing "special" about method names that end in "?" - it's only conventional that they return a boolean, and they don't necessarily have no arguments. In your example some_method? a : b how does ruby and the reader distinguish whether 'a' is 1) the first option for the ternary operator's return value or 2) the first argument to some_method? As an example, this syntax doesn't look quite so appealing... an_array.include? val x : y alex [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Ruby
Ternary operator request
Top