23件ヒット
[1-23件を表示]
(0.018秒)
クラス
- Method (6)
- Proc (6)
-
Process
:: Status (11)
検索結果
-
Proc
# >>(callable) -> Proc (39279.0) -
self と引数を合成した Proc を返します。
...成した Proc を返します。
戻り値の Proc は可変長の引数を受け取ります。
戻り値の Proc を呼び出すと、まず受け取った引数を self に渡して呼び出し、
その戻り値を callable に渡して呼び出した結果を返します。
Proc#<< とは呼......出しの順序が逆になります。
@param callable Proc、Method、もしくは任意の call メソッドを持ったオブジェクト。
//emlist[例][ruby]{
f = proc { |x| x * x }
g = proc { |x| x + x }
# (3 * 3) + (3 * 3)
p (f >> g).call(3) # => 18
//}
//emlist[call を定義したオ......anner
def self.call(str)
str.scan(/\w+/)
end
end
File.write('testfile', <<~TEXT)
Hello, World!
Hello, Ruby!
TEXT
pipeline = proc { |fname| File.read(fname) } >> WordScanner >> method(:p)
pipeline.call('testfile') # => ["Hello", "World", "Hello", "Ruby"]
//}
@see Method#<<, Method#>>... -
Process
:: Status # >>(num) -> Integer (21124.0) -
self.to_i >> num と同じです。
...self.to_i >> num と同じです。
@param num 整数を指定します。
fork { exit 99 } #=> 26563
Process.wait #=> 26563
$?.to_i #=> 25344
$? >> 8 #=> 99... -
Method
# >>(callable) -> Proc (18267.0) -
self と引数を合成した Proc を返します。
...self と引数を合成した Proc を返します。
戻り値の Proc は可変長の引数を受け取ります。
戻り値の Proc を呼び出すと、まず受け取った引数を self に渡して呼び出し、
その戻り値を callable に渡して呼び出した結果を返します......しの順序が逆になります。
@param callable Proc、Method、もしくは任意の call メソッドを持ったオブジェクト。
//emlist[例][ruby]{
def f(x)
x * x
end
def g(x)
x + x
end
# (3 * 3) + (3 * 3)
p (method(:f) >> method(:g)).call(3) # => 18
//}
//emlist[call を定......uby]{
class WordScanner
def self.call(str)
str.scan(/\w+/)
end
end
File.write('testfile', <<~TEXT)
Hello, World!
Hello, Ruby!
TEXT
pipeline = File.method(:read) >> WordScanner >> method(:pp)
pipeline.call('testfile') # => ["Hello", "World", "Hello", "Ruby"]
//}
@see Proc#<<, Proc#>>...