Do it exist a way to define setter() method for local variables (like for
global variables) ?
I want to write something like this.
pigeon% cat b.rb
#!/usr/bin/ruby
require "bdb"
db = BDB::Btree.open("aa", nil, BDB::CREATE, {"marshal" => true})
db[[1, 2]] = ["a", "b"]
db[[1, 2]].push(3)
db.close
bd = BDB::Btree.open("aa", {"marshal" => true})
bd.each do |x, y|
print "Key : "
x.each do |z|
print "#{z} "
end
print "\nValue : "
y.each do |z|
print "#{z} "
end
print "\n"
end
bd.close
pigeon% b.rb
Key : 1 2
Value : a b
pigeon%
Actually it don't work because db[[1, 2]] return a temporary array,
this array is modified and the modification is not propagated to db. I
want to put a setter() on the temporary array to try to propagate the
modification.
The result I want to have is :
pigeon% b.rb
Key : 1 2
Value : a b 3
pigeon%
bdb is an extension (written in C), if this has an importance.
Guy Decoux