Created
October 23, 2012 01:39
-
-
Save ymek/3936163 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
| # In this scenario, we initialize the variable, | |
| # which is parsed *after* we access it, because | |
| # the interpreter is always left-to-right. | |
| [] << walrus if (walrus = :bubbles) | |
| # Note: the value *does* change before the append | |
| # happens. | |
| walrus = nil | |
| [] << walrus if (walrus = :bubbles) | |
| # To better illustrate this, let's use our | |
| # friend, nil. No NameError here. | |
| [] << nil if (walrus = :bubbles) | |
| # Could also do something like this in your sample | |
| [] << walrus || :bubbles |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment