Skip to content

Instantly share code, notes, and snippets.

@Dasms
Created November 9, 2017 18:39
Show Gist options
  • Save Dasms/dc724712d2be4b03f150b97ad2da5e41 to your computer and use it in GitHub Desktop.
Save Dasms/dc724712d2be4b03f150b97ad2da5e41 to your computer and use it in GitHub Desktop.
# this one is just like your scripts with ARGV
def print_two(*args)
arg1, arg2 = args
puts "arg1: #{arg1}, arg2: #{arg2}"
end
# That *args is actually pointless, we can just do this:
def print_two_again(arg1, arg2)
puts "arg1: #{arg1}, arg2: #{arg2}"
end
# Just 1 argument
def print_one(arg1)
puts "arg1: #{arg1}"
end
# No arguments
def print_none
puts "I got nothin'."
end
print_two("Idaho","Potato")
print_two_again("Idaho","Potato")
print_one("First!")
print_none()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment