Required, default, and optional parameters

suggest change
def my_mix(name, valid = true, *opt)
    puts name
    puts valid
    puts opt
end

Call as follows:

my_mix('me')
# me
# true

my_mix('me', false)
# me
# false

my_mix('me', true, 5, 7)
# me
# true
# 5
# 7

puts on the splat array writes each element on its own line. An empty array produces no line.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents