Last active
June 1, 2020 02:02
-
-
Save kleytonmr/88d2e9fb2235eefdb184600e656c05be to your computer and use it in GitHub Desktop.
Try convert
This file contains hidden or 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 Stooges | |
def to_ary | |
%w[larry Curly Moe] | |
end | |
end | |
a = Stooges.new # => #<Stooges:0x00007f92438f6678> | |
a.class # => Stooges | |
b = Array.try_convert(Stooges.new) # => ["larry", "Curly", "Moe"] | |
b.class # => Array | |
Array.try_convert('Shemp') # => nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment