るりまサーチ (Ruby 3.0)

最速Rubyリファレンスマニュアル検索!
10件ヒット [1-10件を表示] (0.211秒)
トップページ > 種類:インスタンスメソッド[x] > クエリ:t[x] > クエリ:-[x] > クエリ:p[x] > バージョン:3.0[x] > クラス:Struct[x]

別のキーワード

  1. openssl t61string
  2. asn1 t61string
  3. matrix t
  4. t61string new
  5. fiddle type_size_t

ライブラリ

キーワード

検索結果

Struct#inspect -> String (36907.0)

self の内容を人間に読みやすい文字列にして返します。

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

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

Struct#each_pair -> Enumerator (27925.0)

構造体のメンバ名(Symbol)と値の組を引数にブロックを繰り返し実行します。

...[ruby]{
Foo = Struct.new(:foo, :bar)
Foo.new('FOO', 'BAR').each_pair {|m, v| p [m,v]}
# => [:foo, "FOO"]
# [:bar, "BAR"]
//}

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

Struct#each_pair {|member, value| ... } -> self (27625.0)

構造体のメンバ名(Symbol)と値の組を引数にブロックを繰り返し実行します。

...[ruby]{
Foo = Struct.new(:foo, :bar)
Foo.new('FOO', 'BAR').each_pair {|m, v| p [m,v]}
# => [:foo, "FOO"]
# [:bar, "BAR"]
//}

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

Struct#to_s -> String (27607.0)

self の内容を人間に読みやすい文字列にして返します。

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

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

Struct#values_at(*members) -> [object] (18625.0)

引数で指定されたメンバの値の配列を返します。

...]{
Foo = Struct.new(:foo, :bar, :baz)
obj = Foo.new('FOO', 'BAR', 'BAZ')
p obj.values_at(0, 1, 2) # => ["FOO", "BAR", "BAZ"]
//}

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

絞り込み条件を変える

Struct#[](member) -> object (9733.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#==(other) -> bool (9661.0)

self と other のクラスが同じであり、各メンバが == メソッドで比較して等しい場合に true を返します。そうでない場合に false を返します。

...//emlist[例][ruby]{
Dog = Struct.new(:name, :age)
dog1 = Dog.new("fred", 5)
dog2 = Dog.new("fred", 5)

p dog1 == dog2 #=> true
p dog1.eql?(dog2) #=> true
p dog1.equal?(dog2) #=> false
//}

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

@see Struct#eql?...

Struct#eql?(other) -> bool (9661.0)

self と other のクラスが同じであり、各メンバが eql? メソッドで比較して等しい場合に true を返します。そうでない場合に false を返します。

...//emlist[例][ruby]{
Dog = Struct.new(:name, :age)
dog1 = Dog.new("fred", 5)
dog2 = Dog.new("fred", 5)

p dog1 == dog2 #=> true
p dog1.eql?(dog2) #=> true
p dog1.equal?(dog2) #=> false
//}

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

@see Struct#==...

Struct#hash -> Integer (9661.0)

self が保持するメンバのハッシュ値を元にして算出した整数を返します。 self が保持するメンバの値が変化すればこのメソッドが返す値も変化します。

...も変化します。

//emlist[例][ruby]{
Dog = Struct.new(:name, :age)
dog = Dog.new("fred", 5)
p dog.hash #=> 7917421
dog.name = "john"
p dog.hash #=> -38913223
//}

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

Struct#members -> [Symbol] (9325.0)

構造体のメンバの名前(Symbol)の配列を返します。

...ます。

//emlist[例][ruby]{
Foo = Struct.new(:foo, :bar)
p Foo.new.members # => [:foo, :bar]
//}

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

絞り込み条件を変える