Skip to content

Instantly share code, notes, and snippets.

@georgekettle
Created January 11, 2021 23:36
Show Gist options
  • Save georgekettle/36fbbdf241798a17b1a96637e7120639 to your computer and use it in GitHub Desktop.
Save georgekettle/36fbbdf241798a17b1a96637e7120639 to your computer and use it in GitHub Desktop.
ruby basics
enthusiasm = 10
love_x = "love " * enthusiasm
comment = "I #{love_x}LeWagon"
# airbnb listings // defining an array
listings = []
def congratulate_dog(name)
# "Good boy Kai"
return "Good boy #{name.capitalize}"
end
puts congratulate_dog("kai")
puts congratulate_dog("yuki")
# max number
def max_number(x, y)
puts "starting method"
# return the biggest one
if x > y
return x
else
return y
end
return 0
end
p max_number(100, 6)
# current population
# growth number
def calculate_population(current, growth)
return current + growth
end
p calculate_population(10000, 333)
# must require the date object to use it's functions (it's a little different to String, Integer, Array etc)
require 'date'
def tomorrow
tomorrow_date = Date.today + 1
tomorrow_date.strftime("%B %d")
end
puts tomorrow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment