るりまサーチ

最速Rubyリファレンスマニュアル検索!
24件ヒット [1-24件を表示] (0.025秒)
トップページ > クエリ:j[x] > クエリ:deconstruct[x]

別のキーワード

  1. encoding windows_31j
  2. _builtin windows_31j
  3. encoding cswindows31j
  4. _builtin cswindows31j
  5. json j

ライブラリ

クラス

キーワード

検索結果

Data#deconstruct -> [object] (18213.0)

self のメンバの値を配列で返します。

...(10, 'km')
distance.deconstruct # => [10, "km"]
//}

このメソッドは以下のようにパターンマッチで利用されます。

//emlist[例][ruby]{
Measure = Data.define(:amount, :unit)
distance = Measure.new(10, 'km')

case distance
in n, 'km' # 裏側で #deconstruct を呼ぶ
puts "...
......
end
//}

[注意] 本メソッドの記述は Data のサブクラスのインスタンスに対して呼び
出す事を想定しています。Data.define は Data のサブクラスを作成する点に
注意してください。

@see d:spec/pattern_matching#matching_non_primitive_objects...

CSV::Row#deconstruct -> [object] (18201.0)

パターンマッチに使用する行の値の配列を返します。

...3])
case row
in [2.., 2.., 2..]
puts "all 2 or more"
in [...2, 2.., 2..]
puts "first column is less than 2, and rest columns are 2 or more"
end
#=> "first column is less than 2, and rest columns are 2 or more" が出力される
//}

@see d:spec/pattern_matching#matching_non_primitive_objects...

Struct#deconstruct -> [object] (18201.0)

構造体のメンバの値を配列にいれて返します。

...値を配列にいれて返します。

//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345).to_a
# => ["Joe Smith", "123 Maple, Anytown NC", 12345]
//}

[注意] 本メソッドの記述は Struct の下位クラスのインス...
...タンスに対して呼び
出す事を想定しています。Struct.new は Struct の下位クラスを作成する点に
注意してください。

@see d:spec/pattern_matching#matching_non_primitive_objects...

Struct#to_a -> [object] (3101.0)

構造体のメンバの値を配列にいれて返します。

...値を配列にいれて返します。

//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345).to_a
# => ["Joe Smith", "123 Maple, Anytown NC", 12345]
//}

[注意] 本メソッドの記述は Struct の下位クラスのインス...
...タンスに対して呼び
出す事を想定しています。Struct.new は Struct の下位クラスを作成する点に
注意してください。

@see d:spec/pattern_matching#matching_non_primitive_objects...

Struct#values -> [object] (3101.0)

構造体のメンバの値を配列にいれて返します。

...値を配列にいれて返します。

//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345).to_a
# => ["Joe Smith", "123 Maple, Anytown NC", 12345]
//}

[注意] 本メソッドの記述は Struct の下位クラスのインス...
...タンスに対して呼び
出す事を想定しています。Struct.new は Struct の下位クラスを作成する点に
注意してください。

@see d:spec/pattern_matching#matching_non_primitive_objects...

絞り込み条件を変える