Doesn't seem so:
require 'schmooze'
class BabelSchmoozer < Schmooze::Base
method :version, 'function(mydict) { mydict["b"] = 2}'
end
babel = BabelSchmoozer.new(__dir__)
mydict = { 'a': 1 }
babel.version(mydict)
puts mydict
outputs:
But I found a reasonable workaround, which is to pass the value back on the return, and use an array of return values if I need more than one return object:
require 'schmooze'
class BabelSchmoozer < Schmooze::Base
method :version, 'function(mydict) { mydict["b"] = 2; return mydict}'
end
babel = BabelSchmoozer.new(__dir__)
mydict = { 'a': 1 }
mydict = babel.version(mydict)
puts mydict
outputs:
and if the goal is to preserve a state parameter across calls, you can use the global object itself!
require 'schmooze'
class BabelSchmoozer < Schmooze::Base
dependencies babel: 'babel-core'
method :init, 'function() { babel.cirosantilli_mydict = []; }'
method :version, 'function(val) { babel.cirosantilli_mydict.push(val); return babel.cirosantilli_mydict; }'
end
babel = BabelSchmoozer.new(__dir__)
babel.init
puts babel.version(0)
puts babel.version(1)
Tested on schmooze (0.2.0).
Doesn't seem so:
outputs:
But I found a reasonable workaround, which is to pass the value back on the return, and use an array of return values if I need more than one return object:
outputs:
and if the goal is to preserve a state parameter across calls, you can use the global object itself!
Tested on schmooze (0.2.0).