[#1816] Ruby 1.5.3 under Tru64 (Alpha)? — Clemens Hintze <clemens.hintze@...>

Hi all,

17 messages 2000/03/14

[#1989] English Ruby/Gtk Tutorial? — schneik@...

18 messages 2000/03/17

[#2241] setter() for local variables — ts <decoux@...>

18 messages 2000/03/29

[ruby-talk:02241] setter() for local variables

From: ts <decoux@...>
Date: 2000-03-29 11:58:08 UTC
List: ruby-talk #2241

 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

In This Thread

Prev Next