るりまサーチ

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

別のキーワード

  1. _builtin file?
  2. _builtin file
  3. file size
  4. file open
  5. file path

ライブラリ

検索結果

Proc#>>(callable) -> Proc (18131.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#>>...