DEV Community

Discussion on: How to return multiple values in ruby

Collapse
 
michaelcurrin profile image
Michael Currin

Thanks, I was looking for how to return a tuple.

Tip - you can unpack all the variables in one line.

def foo
  return "abc", 2, true
end

a, b, c = foo()
a
# "abc"
b
# 2
c
# true
Enter fullscreen mode Exit fullscreen mode