Parallel assignment and that comma
These have different results:
first_thing, = ["foo", "bar"] # first_thing is a String, "foo"
first_thing = ["foo", "bar"] # first_thing is the Array ["foo", "bar"]
The first statement can be more verbose:
first_thing, * = ["foo", "bar", "baz"]
Written by Melanie Archer
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#