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
The ||= assignment operator
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="Joshua Ballanco, post: 4602094"] Not at all. Rather, this is just a subtle misunderstanding of how hash is implemented. Consider the following: => {} The only reason that Chris' example behaves like "x || x = stuff" is because he's defined a default value for the hash. If you set a default value, than you'll never have a keyed value be empty (i.e. nil). Consider further: empty => nil I think the confusion is that, in Chris' example, there's no assignment, so the hash only holds the default value temporarily (i.e. just long enough to not evaluate to nil or false). [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Ruby
The ||= assignment operator
Top