Created
March 16, 2018 02:29
-
-
Save xenocampanoli/83eff64cf27c1df76a75d7207236616c to your computer and use it in GitHub Desktop.
Example of case not working with class
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
xeno@xeno-Latitude-E7450:~/garage/ex15$ ruby try3.rb | |
trace Array | |
NOPE | |
trace String | |
NOPE | |
trace MyThingy | |
NOPE | |
trace Hash | |
NOPE | |
xeno@xeno-Latitude-E7450:~/garage/ex15$ cat try3.rb | |
class MyThingy | |
end | |
def caseyMeth(someArg) | |
puts "trace #{someArg.class}" | |
case someArg.class | |
when Array | |
puts "Array" | |
when String | |
puts "String" | |
when MyThingy | |
puts "MyThingy" | |
else | |
puts "NOPE" | |
end | |
end | |
caseyMeth(Array.new) | |
caseyMeth("Some string") | |
caseyMeth(MyThingy.new) | |
caseyMeth(Hash.new) | |
xeno@xeno-Latitude-E7450:~/garage/ex15$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment