33件ヒット
[1-33件を表示]
(0.050秒)
検索結果
-
Struct
# size -> Integer (23122.0) -
構造体のメンバの数を返します。
...の記述は Struct の下位クラスのインスタンスに対して呼び
出す事を想定しています。Struct.new は Struct の下位クラスを作成する点に
注意してください。
//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
joe = Customer.new("Joe Smith... -
Struct
# [](member) -> object (8027.0) -
構造体のメンバの値を返します。
...指定した場合に発生します。
//emlist[例][ruby]{
Foo = Struct.new(:foo, :bar)
obj = Foo.new('FOO', 'BAR')
p obj[:foo] # => "FOO"
p obj['bar'] # => "BAR"
# p obj[:baz] # => in `[]': no member 'baz' in struct (NameError)
p obj[0] # => "FOO"
p obj[1] # => "BAR"
p o......p obj[2] # => in `[]': offset 2 too large for struct(size:2) (IndexError)
//}
[注意] 本メソッドの記述は Struct の下位クラスのインスタンスに対して呼び
出す事を想定しています。Struct.new は Struct の下位クラスを作成する点に
注意して... -
Struct
# length -> Integer (8022.0) -
構造体のメンバの数を返します。
...の記述は Struct の下位クラスのインスタンスに対して呼び
出す事を想定しています。Struct.new は Struct の下位クラスを作成する点に
注意してください。
//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
joe = Customer.new("Joe Smith...