On 8/24/07, John Dearden <john.dearden / earthlink.net> wrote: > I am trying to write a method that changes the value of two arguments. > Stripped to the barest essentials, something like this: > > def munge(a) > a = a + 1 > end > > zot = 3 > print zot, "\n" # this should (and does) print '3' > munge(zot) > print zot, "\n" # this should print '4'. We wouldn't be here now if it > did! > > Now, if I try the amend method given by David A. Black, it works as > expected. But it's passing a string object, not an integer. > > Surely there is a way to give a method _something_ so that it can return > values to the caller. Of course, if I only ever had a single value to > return, I could make it the return value, but that's just begging the > question. or you can return more than one value def munge(a, b) return a + 1, b - 2 end q = 4 r = 9 q, r = munge(q, r) > > Thanks in advance, > John > -- > Posted via http://www.ruby-forum.com/. > >