Created
April 21, 2015 15:45
-
-
Save IceDragon200/3f9a2f02064ba2706dd8 to your computer and use it in GitHub Desktop.
This file contains 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
class Object | |
# Attempts to wrap the object into an Array if it isnt already one. | |
# | |
# @return [Array] | |
def to_arylist | |
[self] | |
end | |
end | |
class Array | |
# (see Object#to_arylist) | |
def to_arylist | |
self.dup | |
end | |
end | |
# var1 = {a:2,c:3}; var2 = [{a:2,c:3}]; [var1, var2].map { |obj| obj.to_arylist } #=> [[{:a=>2, :c=>3}], [{:a=>2, :c=>3}]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment