The better syntax?

first i had this (i pass bindings in afterward):

bindings = {
name => {
:value => Proc.new { fruitapp.fruit.isa },
:value= => Proc.new { |x| fruitapp.fruit.isa = x },
:items => Proc.new { fruitapp.fruitbasket.contains },
:event_change => Proc.new { fruitapp.pickafruit }
}
}

then i thought maybe this:

mygui.bind(name, :value) { fruitapp.fruit.isa }
mygui.bind(name, :value=) { |x| fruitapp.fruit.isa = x },
mygui.bind(name, :items) { fruitapp.fruitbasket.contains },
mygui.bind(name, :event_change) { fruitapp.pickafruit }

a friend suggested this:

mygui.bind(name,
:value => Proc.new { fruitapp.fruit.isa },
:value= => Proc.new { |x| fruitapp.fruit.isa = x },
:items => Proc.new { fruitapp.fruitbasket.contains },
:event_change => Proc.new { fruitapp.pickafruit }
)

or i could do this using #missing_method

mygui.bind(name) {
value { fruitapp.fruit.isa }
value= { |x| fruitapp.fruit.isa = x }
items { fruitapp.fruitbasket.contains }
event_change { fruitapp.pickafruit }
}

which is better?

~transami

p.s. okay that’ll be my last post for a while i gots to get some work
done!

Hi,

then i thought maybe this:

mygui.bind(name, :value) { fruitapp.fruit.isa }
mygui.bind(name, :value=) { |x| fruitapp.fruit.isa = x },
mygui.bind(name, :items) { fruitapp.fruitbasket.contains },
mygui.bind(name, :event_change) { fruitapp.pickafruit }

a friend suggested this:

mygui.bind(name,
:value => Proc.new { fruitapp.fruit.isa },
:value= => Proc.new { |x| fruitapp.fruit.isa = x },
:items => Proc.new { fruitapp.fruitbasket.contains },
:event_change => Proc.new { fruitapp.pickafruit }
)

I guess these two syntaxes can be consistent, the former when a
block (or an proc as third argument) is given, or the latter.

or i could do this using #missing_method

mygui.bind(name) {
value { fruitapp.fruit.isa }
value= { |x| fruitapp.fruit.isa = x }

This can’t work as you expect. Assign to local variable (maybe
in the block).

And which method_missing will you modify? I don’t guess it’s
good idea to modify caller’s methods.

···

At Fri, 26 Jul 2002 04:16:39 +0900, Tom Sawyer wrote:


Nobu Nakada

Thanks Nobu. I think your right. i’ll stear clear of the last.

···

On Thu, 2002-07-25 at 20:23, nobu.nokada@softhome.net wrote:

And which method_missing will you modify? I don’t guess it’s
good idea to modify caller’s methods.


~transami