4件ヒット
[1-4件を表示]
(0.134秒)
検索結果
先頭4件
-
Method
# call(*args) -> object (9343.0) -
メソッドオブジェクトに封入されているメソッドを起動します。
...ありません。
@param args self に渡される引数。
@see UnboundMethod#bind_call
//emlist[例][ruby]{
class Foo
def foo(arg)
"foo called with arg #{arg}"
end
end
m = Foo.new.method(:foo) # => #<Method: Foo#foo>
m[1] # => "foo called with arg 1"
m.call(2) # => "foo called w... -
Method
# call(*args) { . . . } -> object (9343.0) -
メソッドオブジェクトに封入されているメソッドを起動します。
...ありません。
@param args self に渡される引数。
@see UnboundMethod#bind_call
//emlist[例][ruby]{
class Foo
def foo(arg)
"foo called with arg #{arg}"
end
end
m = Foo.new.method(:foo) # => #<Method: Foo#foo>
m[1] # => "foo called with arg 1"
m.call(2) # => "foo called w... -
Method
# <<(callable) -> Proc (343.0) -
self と引数を合成した Proc を返します。
...ます。
Method#>> とは呼び出しの順序が逆になります。
@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......uby]{
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 Proc#<<, Proc#>>... -
Method
# >>(callable) -> Proc (343.0) -
self と引数を合成した Proc を返します。
...ます。
Method#<< とは呼び出しの順序が逆になります。
@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......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#>>...