Call method to generate arguments in ruby works in 1.8.7 but not 1.9.3

96 views Asked by At

This is something that I had working in ruby 1.8.7, but no longer works in 1.9.3, and I am not sure what changes make this fail.

Previously, I had something like this

myFunction(submitArgs())

where submitArgs was a helper method that could be called with some options

def submitArgs(args={})
  #Some logic/manipulations
  ["Text", args]
end

Then myFunction would be called with the first argument "Text", and the second a hash. Now in 1.9.3, it is being called with "Text {}" all as one big string.

Does anyone know what change was made between the ruby versions that causes this, and if there is an alternative to returning an array of arguments in 1.9.3?

1

There are 1 answers

3
Aleksei Matiushkin On BEST ANSWER

Change required (in github notation):

- myFunction(submitArgs())
+ myFunction(*submitArgs)

The reason that [I assume] myFunction is declared taking two arguments:

def myFunction a1, a2

Hence the array must be splatted before passing to it. I wonder how that worked in 1.8.