88件ヒット
[1-88件を表示]
(0.014秒)
検索結果
先頭5件
-
Object
# yield _ self -> Enumerator (6139.0) -
self を引数としてブロックを評価し、ブロックの結果を返します。
...f を引数としてブロックを評価し、ブロックの結果を返します。
//emlist[例][ruby]{
"my string".yield_self {|s| s.upcase } # => "MY STRING"
3.next.yield_self {|x| x**x }.to_s # => "256"
//}
値をメソッドチェインのパイプラインに次々と渡すのは.......
yield_self {|url| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}
ブロックなしで呼び出されたときは Enumerator を返します。
例えば条件によって値を捨てるのに使えます。
//emlist[][ruby]{
# 条件にあうので何もしない
1.yield......_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}
@see Object#tap... -
Object
# yield _ self {|x| . . . } -> object (6139.0) -
self を引数としてブロックを評価し、ブロックの結果を返します。
...f を引数としてブロックを評価し、ブロックの結果を返します。
//emlist[例][ruby]{
"my string".yield_self {|s| s.upcase } # => "MY STRING"
3.next.yield_self {|x| x**x }.to_s # => "256"
//}
値をメソッドチェインのパイプラインに次々と渡すのは.......
yield_self {|url| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}
ブロックなしで呼び出されたときは Enumerator を返します。
例えば条件によって値を捨てるのに使えます。
//emlist[][ruby]{
# 条件にあうので何もしない
1.yield......_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}
@see Object#tap... -
Object
# yield _ self -> Enumerator (3133.0) -
self を引数としてブロックを評価し、ブロックの結果を返します。
...string".yield_self {|s| s.upcase } # => "MY STRING"
//}
値をメソッドチェインのパイプラインに次々と渡すのは良い使い方です。
//emlist[メソッドチェインのパイプライン][ruby]{
require 'open-uri'
require 'json'
construct_url(arguments).
yield_self {|......l| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}
ブロックなしで呼び出されたときは Enumerator を返します。
例えば条件によって値を捨てるのに使えます。
//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?......) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}
@see Object#tap... -
Object
# yield _ self {|x| . . . } -> object (3133.0) -
self を引数としてブロックを評価し、ブロックの結果を返します。
...string".yield_self {|s| s.upcase } # => "MY STRING"
//}
値をメソッドチェインのパイプラインに次々と渡すのは良い使い方です。
//emlist[メソッドチェインのパイプライン][ruby]{
require 'open-uri'
require 'json'
construct_url(arguments).
yield_self {|......l| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}
ブロックなしで呼び出されたときは Enumerator を返します。
例えば条件によって値を捨てるのに使えます。
//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?......) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}
@see Object#tap... -
Object
# then -> Enumerator (33.0) -
self を引数としてブロックを評価し、ブロックの結果を返します。
...string".yield_self {|s| s.upcase } # => "MY STRING"
//}
値をメソッドチェインのパイプラインに次々と渡すのは良い使い方です。
//emlist[メソッドチェインのパイプライン][ruby]{
require 'open-uri'
require 'json'
construct_url(arguments).
yield_self {|......l| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}
ブロックなしで呼び出されたときは Enumerator を返します。
例えば条件によって値を捨てるのに使えます。
//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?......) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}
@see Object#tap... -
Object
# then {|x| . . . } -> object (33.0) -
self を引数としてブロックを評価し、ブロックの結果を返します。
...string".yield_self {|s| s.upcase } # => "MY STRING"
//}
値をメソッドチェインのパイプラインに次々と渡すのは良い使い方です。
//emlist[メソッドチェインのパイプライン][ruby]{
require 'open-uri'
require 'json'
construct_url(arguments).
yield_self {|......l| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}
ブロックなしで呼び出されたときは Enumerator を返します。
例えば条件によって値を捨てるのに使えます。
//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?......) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}
@see Object#tap... -
Object
# enum _ for(method = :each , *args) -> Enumerator (7.0) -
Enumerator.new(self, method, *args) を返します。
...ソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerat... -
Object
# enum _ for(method = :each , *args) {|*args| . . . } -> Enumerator (7.0) -
Enumerator.new(self, method, *args) を返します。
...ソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerat... -
Object
# tap {|x| . . . } -> self (7.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
# to _ enum(method = :each , *args) -> Enumerator (7.0) -
Enumerator.new(self, method, *args) を返します。
...ソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerat... -
Object
# to _ enum(method = :each , *args) {|*args| . . . } -> Enumerator (7.0) -
Enumerator.new(self, method, *args) を返します。
...ソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerat... -
Object
# to _ proc -> Proc (7.0) -
オブジェクトの Proc への暗黙の変換が必要なときに内部で呼ばれます。 デフォルトでは定義されていません。
...こに記載してありますが、
このメソッドは実際には Object クラスには定義されていません。
必要に応じてサブクラスで定義すべきものです。
//emlist[][ruby]{
def doing
yield
end
class Foo
def to_proc
Proc.new{p 'ok'}
end
end
it = Foo.ne...