Skip to content

Instantly share code, notes, and snippets.

@waynegraham
Created October 27, 2010 16:59
Show Gist options
  • Save waynegraham/649452 to your computer and use it in GitHub Desktop.
Save waynegraham/649452 to your computer and use it in GitHub Desktop.
@base_value = 5
@string_value = "This is awesome!!! "
def write_awesome_stuff
puts "Ruby is an awesome language"
end
def write_message(name)
puts "#{name} is an awesome programmer."
end
def multiply(x,y)
return x * y
end
def subtract(x,y)
x - y
end
def smallest_number(x,y)
if x < y
return x
elsif x == y
return "They're the same!"
else
return y
end
end
def numbers val
val.each {|i| print i, "\n"}
end
def false? val
if val == 'false' || val == 0
return true
else
return false
end
end
def base!(val)
@base_value = val
end
def reverse!
@string_value.reverse!
end
puts multiply(8,9)
puts subtract(3,1)
puts smallest_number(5,5)
puts false?(true)
puts false?(false)
puts false?('false')
puts @base_value
puts base! 7
puts @base_value
puts numbers(["one", "two", "3", "4", "5",])
puts @string_value
puts @string_value.reverse!
puts @string_value.strip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment