るりまサーチ

最速Rubyリファレンスマニュアル検索!
136件ヒット [1-100件を表示] (0.120秒)
トップページ > クエリ:self[x] > クエリ:t[x] > クラス:Struct[x]

別のキーワード

  1. object yield_self
  2. _builtin yield_self
  3. _builtin self
  4. tracepoint self
  5. codeobject document_self

ライブラリ

キーワード

検索結果

<< 1 2 > >>

Struct#inspect -> String (6117.0)

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

...
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#to_h -> Hash (6117.0)

self のメンバ名(Symbol)と値の組を Hash にして返します。

...
self
のメンバ名(Symbol)と値の組を Hash にして返します。

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


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

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

ブロックを...
...ます。
//emlist[ブロック付きの例][ruby]{
Customer = Struct.new(:name, :address, :zip)
Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345).to_h {|member, value|
[member, value*2]
} # => {:name=>"Joe SmithJoe Smith", :address=>"123 Maple, Anytown NC123 Maple, Anytown NC", :zip=>2469...
...0}
//}

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

Struct#to_h {|member, value| block } -> Hash (6117.0)

self のメンバ名(Symbol)と値の組を Hash にして返します。

...
self
のメンバ名(Symbol)と値の組を Hash にして返します。

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

ブロックを...
...ます。
//emlist[ブロック付きの例][ruby]{
Customer = Struct.new(:name, :address, :zip)
Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345).to_h {|member, value|
[member, value*2]
} # => {:name=>"Joe SmithJoe Smith", :address=>"123 Maple, Anytown NC123 Maple, Anytown NC", :zip=>2469...
...0}
//}

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

Struct#to_s -> String (6117.0)

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

...
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#hash -> Integer (3133.0)

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

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

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

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

絞り込み条件を変える

Struct#==(other) -> bool (3123.0)

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

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

@param other self と比較したいオブジェクトを指定します。

//emlist[例][ruby]{
Dog = Struct.n...
...== dog2 #=> true
p dog1.eql?(dog2) #=> true
p dog1.equal?(dog2) #=> false
//}

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

@see Struct#eql?...

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

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

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

@param other self と比較したいオブジェクトを指定します。

//emlist[例][ruby]{
Dog = Struct...
...== dog2 #=> true
p dog1.eql?(dog2) #=> true
p dog1.equal?(dog2) #=> false
//}

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

@see Struct#==...

Struct#dig(key, ...) -> object | nil (3117.0)

self 以下のネストしたオブジェクトを dig メソッドで再帰的に参照して返し ます。途中のオブジェクトが nil であった場合は nil を返します。

...
self
以下のネストしたオブジェクトを dig メソッドで再帰的に参照して返し
ます。途中のオブジェクトが nil であった場合は nil を返します。

@param key キーを任意個指定します。

//emlist[例][ruby]{
klass = Struct.new(:a)
o = klass.new(k...
...lass.new({b: [1, 2, 3]}))

o.dig(:a, :a, :b, 0) # => 1
o.dig(:b, 0) # => nil
//}

@see Array#dig, Hash#dig, OpenStruct#dig...

Struct#equal?(other) -> bool (3117.0)

指定された other が self 自身である場合のみ真を返します。 これは Object クラスで定義されたデフォルトの動作で す。

...other が self 自身である場合のみ真を返します。
これは Object クラスで定義されたデフォルトの動作で
す。

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


@see Struct#eql?, Struct#==...

Struct#each -> Enumerator (3102.0)

構造体の各メンバに対して繰り返します。

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

//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
joe = Customer.new("Joe Smith", "12...
...3 Maple, Anytown NC", 12345)
joe.each {|x| puts(x) }

# => Joe Smith
# 123 Maple, Anytown NC
# 12345
//}...

絞り込み条件を変える

<< 1 2 > >>