Skip to content

Instantly share code, notes, and snippets.

@arthur-littm
Last active October 18, 2019 07:53
Show Gist options
  • Save arthur-littm/44e4f63c88e765ecde91ea25c3daab74 to your computer and use it in GitHub Desktop.
Save arthur-littm/44e4f63c88e765ecde91ea25c3daab74 to your computer and use it in GitHub Desktop.
require "date"
# def name_of_method(parameters)
def greeting(name)
return "Hello, #{name}"
end
# call the method giving it an argument
# puts greeting("Arthur")
def full_name(first, last)
first_name = first.capitalize
last_name = last.upcase
return "#{first_name} #{last_name}"
end
# puts full_name("ARtHuR", "LittMaNN")
def tomorrows_date()
return (Date.today + 1).strftime("%A, %b %d")
end
# puts tomorrows_date
def max(x, y)
if x > y
return x
else
return y
end
end
first_number = 2
second_number = 5
largest_number = max(first_number, second_number)
puts largest_number # => 5
# Defining a variable called age
age = 25
# Concatenation
# puts "I am " + age.to_s + " years old"
# Interpolation
puts "I am #{age} years old"
# one year passes...
# Reassignment of the variable age
# age = (age + 1)
# Incrementation
age += 1
puts "Happy birthday you are now #{age}"
puts age
puts "What's your first name"
first_name = gets.chomp
puts "What's your last name"
last_name = "Smith"
# puts "Hello #{first_name} #{last_name}"
puts "Hello " + first_name + " " + last_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment