キーワード
- <=> (1)
-
enum
_ for (2) -
instance
_ variable _ get (1) -
pretty
_ print (1) -
pretty
_ print _ instance _ variables (1) -
respond
_ to? (1) - tap (1)
- then (2)
-
to
_ enum (2) -
yield
_ self (2)
検索結果
先頭5件
-
Object
# <=>(other) -> 0 | nil (45664.0) -
self === other である場合に 0 を返します。そうでない場合には nil を返します。
...self === other である場合に 0 を返します。そうでない場合には nil を返します。
//emlist[例][ruby]{
a = Object.new
b = Object.new
a <=> a # => 0
a <=> b # => nil
//}
@see Object#===... -
Object
# then {|x| . . . } -> object (28009.0) -
self を引数としてブロックを評価し、ブロックの結果を返します。
...返します。
例えば条件によって値を捨てるのに使えます。
//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}
@see Object#tap... -
Object
# yield _ self {|x| . . . } -> object (28009.0) -
self を引数としてブロックを評価し、ブロックの結果を返します。
...返します。
例えば条件によって値を捨てるのに使えます。
//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}
@see Object#tap... -
Object
# instance _ variable _ get(var) -> object | nil (27967.0) -
オブジェクトのインスタンス変数の値を取得して返します。
...Foo
def initialize
@foo = 1
end
end
obj = Foo.new
p obj.instance_variable_get("@foo") #=> 1
p obj.instance_variable_get(:@foo) #=> 1
p obj.instance_variable_get(:@bar) #=> nil
//}
@see Object#instance_variable_set,Object#instance_variables,Object#instance_variable_defined?... -
Object
# tap {|x| . . . } -> self (27736.0) -
self を引数としてブロックを評価し、self を返します。
...目的です。
//emlist[][ruby]{
(1..10) .tap {|x| puts "original: #{x}" }
.to_a .tap {|x| puts "array: #{x}" }
.select {|x| x.even? } .tap {|x| puts "evens: #{x}" }
.map {|x| x*x } .tap {|x| puts "squares: #{x}" }
//}
@see Object#yield_self... -
Object
# enum _ for(method = :each , *args) {|*args| . . . } -> Enumerator (27703.0) -
Enumerator.new(self, method, *args) を返します。
Enumerator.new(self, method, *args) を返します。
ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。
@param method メソッド名の文字列かシンボルです。
@param args 呼び出すメソッドに渡される引数です。
//emlist[][ruby]{
str = "xyz"
enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]
#... -
Object
# to _ enum(method = :each , *args) {|*args| . . . } -> Enumerator (27703.0) -
Enumerator.new(self, method, *args) を返します。
Enumerator.new(self, method, *args) を返します。
ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。
@param method メソッド名の文字列かシンボルです。
@param args 呼び出すメソッドに渡される引数です。
//emlist[][ruby]{
str = "xyz"
enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]
#... -
Object
# pretty _ print _ instance _ variables -> [String | Symbol] (27610.0) -
プリティプリント時に表示すべき自身のインスタンス変数名の配列をソートして返します。 返されたインスタンス変数はプリティプリント時に表示されます。
プリティプリント時に表示すべき自身のインスタンス変数名の配列をソートして返します。
返されたインスタンス変数はプリティプリント時に表示されます。
pp に表示したくないインスタンス変数がある場合にこのメソッドを再定義します。 -
Object
# then -> Enumerator (27409.0) -
self を引数としてブロックを評価し、ブロックの結果を返します。
...返します。
例えば条件によって値を捨てるのに使えます。
//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}
@see Object#tap... -
Object
# yield _ self -> Enumerator (27409.0) -
self を引数としてブロックを評価し、ブロックの結果を返します。
...返します。
例えば条件によって値を捨てるのに使えます。
//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}
@see Object#tap... -
Object
# enum _ for(method = :each , *args) -> Enumerator (27403.0) -
Enumerator.new(self, method, *args) を返します。
Enumerator.new(self, method, *args) を返します。
ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。
@param method メソッド名の文字列かシンボルです。
@param args 呼び出すメソッドに渡される引数です。
//emlist[][ruby]{
str = "xyz"
enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]
#... -
Object
# to _ enum(method = :each , *args) -> Enumerator (27403.0) -
Enumerator.new(self, method, *args) を返します。
Enumerator.new(self, method, *args) を返します。
ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。
@param method メソッド名の文字列かシンボルです。
@param args 呼び出すメソッドに渡される引数です。
//emlist[][ruby]{
str = "xyz"
enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]
#... -
Object
# pretty _ print(pp) -> () (27361.0) -
PP.pp や Kernel.#pp がオブジェクトの内容を出力するときに 呼ばれるメソッドです。PP オブジェクト pp を引数として呼ばれます。
...@param pp PP オブジェクトです。
//emlist[][ruby]{
class Array
def pretty_print(q)
q.group(1, '[', ']') {
q.seplist(self) {|v|
q.pp v
}
}
end
end
//}
@see Object#pretty_print_cycle, Object#inspect, PrettyPrint#text, PrettyPrint#group, PrettyPrint#breakable... -
Object
# respond _ to?(name , include _ all = false) -> bool (27361.0) -
オブジェクトがメソッド name を持つとき真を返します。
...されたメソッドで NotImplementedError が発生する場合は true を返します。
メソッドが定義されていない場合は、Object#respond_to_missing? を呼
び出してその結果を返します。
@param name Symbol または文字列で指定するメソッド名です。...