Created
January 16, 2015 14:54
-
-
Save aguayma/66e95ce3985372ffdba4 to your computer and use it in GitHub Desktop.
Mad_max
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
def mad_max(a,b) | |
if (a.is_a? Fixnum) && (b.is_a? Fixnum) | |
puts [a,b].max | |
else | |
if a||b == String | |
puts "Please put a valid number" | |
end | |
end | |
end | |
p "-------------" | |
def test_mad_max | |
p mad_max(1,"s") | |
#p "-------------" | |
p mad_max(1,4) | |
#p "-------------" | |
p mad_max(-1,0) | |
#p "-------------" | |
p mad_max(0,-1) | |
#p "-------------" | |
p mad_max(12,2) | |
#p "-------------" | |
p mad_max(false, 7) | |
#p "-------------" | |
p mad_max("",4) | |
end | |
test_mad_max |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment