P
Phlip
Ruby-ists:
We all know this clever idiom to turn a variable that might be an Array into
one known to be an Array:
thing = [thing].flatten
That saves a lot of if statements to permit thing's type to overload.
What is the opposite (clever) operation? How to turn a list of one item into
one item, and a list of zero items into nil, but pass thru the list of many
items?
We all know this clever idiom to turn a variable that might be an Array into
one known to be an Array:
thing = [thing].flatten
That saves a lot of if statements to permit thing's type to overload.
What is the opposite (clever) operation? How to turn a list of one item into
one item, and a list of zero items into nil, but pass thru the list of many
items?