ruby cheat sheet pdf 2020 code example
Example 1: best ruby cheat sheet
def greeting(hello, *names) # *name is a splat argument, takes several parameters passed in an array
return "#{hello}, #{names}"
end
start = greeting("Hi", "Justin", "Maria", "Herbert") # call a method by name
def name(variable=default)
### The last line in here get's returned by default
end
Example 2: best ruby cheat sheet
i = 0
loop do
i += 1
print "I'm currently number #{i}” # a way to have ruby code in a string
break if i > 5
end