Skip to content

Instantly share code, notes, and snippets.

@ymek
Created October 23, 2012 01:39
Show Gist options
  • Select an option

  • Save ymek/3936163 to your computer and use it in GitHub Desktop.

Select an option

Save ymek/3936163 to your computer and use it in GitHub Desktop.
# 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