るりまサーチ

最速Rubyリファレンスマニュアル検索!
12件ヒット [1-12件を表示] (0.147秒)

別のキーワード

  1. matrix l
  2. kernel $-l
  3. _builtin $-l
  4. lupdecomposition l
  5. l

ライブラリ

キーワード

検索結果

Method#<<(callable) -> Proc (114.0)

self と引数を合成した Proc を返します。

...self と引数を合成した Proc を返します。

戻り値の Proc は可変長の引数を受け取ります。
戻り値の Proc を呼び出すと、まず受け取った引数を callable に渡して呼び出し、
その戻り値を self に渡して呼び出した結果を返します...
...なります。

@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) # => 36
//}

//emlist[call を定義したオブジェ...
...を渡す例][ruby]{
class WordScanner
def self.call(str)
str.scan(/\w+/)
end
end

File.write('testfile', <<~TEXT)
Hello, World!
Hello, Ruby!
TEXT


pipeline = method(:pp) << WordScanner << File.method(:read)
pipeline.call('testfile') # => ["Hello", "World", "Hello", "Ruby"]
//}

@see Pro...

Method#>>(callable) -> Proc (114.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 を定義したオブジェ...
...を渡す例][ruby]{
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 Pro...