I'm very new to ruby and I have been writing some simple programs. I've noticed that alot of my programs are creating no returned values when I try to run them through the command line, but seem to be working perfectly when I use repl.it for testing. For example:
def rev(a)
b = []
c = []
b = a.scan(/\w+/)
c = b.map {|x| x.reverse }
return c.join(' ')
end
rev('hello')
If I use puts c.join(' ')
the answer will appear but it's not being returned which is what I need to happen. I have a feeling this is something very simple. Any help is appreciated, I've had to create some weird and blocky work arounds to make my other programs work but have limited what I've been able to do.
I'm making this program to fulfill some rspec specifications that were given to me, so simply printing or putting the answer isn't enough, I need the final term evaluated to be the answer.