Skip to content

Instantly share code, notes, and snippets.

@backus
Created July 21, 2016 23:06
Show Gist options
  • Save backus/c9b70dee67470698fd7d4a66ddf0384b to your computer and use it in GitHub Desktop.
Save backus/c9b70dee67470698fd7d4a66ddf0384b to your computer and use it in GitHub Desktop.
What is falsey in multiple assignment?
'truthy' if (a, b = []) # => "truthy"
'truthy' if (a, b = nil) # => nil
'truthy' if (a, b = [nil]) # => "truthy"
'truthy' if (a, b = [nil, nil]) # => "truthy"
'truthy' if (a, b = [false]) # => "truthy"
'truthy' if (a, b = [false, false]) # => "truthy"
'truthy' if (a, b = [true, false]) # => "truthy"
'truthy' if (a, b = [false, true]) # => "truthy"
'truthy' if (a, b = *[]) # => "truthy"
'truthy' if (a, b = *nil) # => "truthy"
'truthy' if (a, b = *[nil]) # => "truthy"
'truthy' if (a, b = *[nil, nil]) # => "truthy"
'truthy' if (a, b = *[false]) # => "truthy"
'truthy' if (a, b = *[false, false]) # => "truthy"
'truthy' if (a, b = *[true, false]) # => "truthy"
'truthy' if (a, b = *[false, true]) # => "truthy"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment