Created
August 3, 2015 07:41
-
-
Save drewdeponte/6e48bdbca04bbec576fb to your computer and use it in GitHub Desktop.
test_default_value_params
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
#!/usr/bin/env ruby | |
def foo(a, b, c = 1, d = 2) | |
puts "a: #{a.inspect}" | |
puts "b: #{b.inspect}" | |
puts "c: #{c.inspect}" | |
puts "d: #{d.inspect}" | |
end | |
puts "Example 1: Two Arguments Passed" | |
puts | |
foo("hi", "there") | |
puts | |
puts "Example 2: Three Arguments Passed" | |
puts | |
foo("hi", "there", "bob") | |
puts | |
puts "Example 3: Four Arguments Passed" | |
puts | |
foo("hi", "there", "bob", "cindy") | |
######################### | |
#### Output of Run Below | |
######################### | |
# | |
# Example 1: Two Arguments Passed | |
# | |
# a: "hi" | |
# b: "there" | |
# c: 1 | |
# d: 2 | |
# | |
# Example 2: Three Arguments Passed | |
# | |
# a: "hi" | |
# b: "there" | |
# c: "bob" | |
# d: 2 | |
# | |
# Example 3: Four Arguments Passed | |
# | |
# a: "hi" | |
# b: "there" | |
# c: "bob" | |
# d: "cindy" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment