Created
February 23, 2009 02:31
-
-
Save geoffreyd/68759 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Ruby assignment option to assign unless nil | |
replacement_content = page_contents.content_label_find(item) | |
element.inner_html = replacement_content if replacement_content | |
# Should be able to do something like... not sure if the "=||" is the best suggestion for the assignment symbols | |
element.inner_html =|| page_contents.content_label_find(item) | |
# I don't think this is quite what you want, but it's a handy little trick: | |
one = false | |
two = nil | |
out ||= one ||= two ||= 3 | |
will return 3, but if 'one' or 'two' are set to something, then the first value that is a non false/nil will be assigned. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment