るりまサーチ

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

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Proc#<<(callable) -> Proc (21243.0)

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

...合成した Proc を返します。

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

P
roc#>> とは...
...@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) # => 36
//}

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

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

p
ipeline = proc { |data| puts "word count: #{data.size}" } << WordScanner << File.method(:read)
p
ipeline.call('testfile') # => word count: 4
//}

@see Method#<<, Method#>>...

OpenSSL::BN#<<(other) -> OpenSSL::BN (21213.0)

自身を other ビット左シフトした値を返します。

...自身を other ビット左シフトした値を返します。

//emlist[][ruby]{
bn = 1.to_bn
p
p bn << 1 # => #<OpenSSL::BN 2>
p
p bn # => #<OpenSSL::BN 1>
//}

@param other シフトするビット数
@raise OpenSSL::BNError 計算時エラー
@see OpenSSL::BN#lshift!...

Psych::Visitors::YAMLTree#<<(object) (21123.0)

変換対象の Ruby オブジェクトを追加します。

...変換対象の Ruby オブジェクトを追加します。

@param object YAML AST へ変換する Ruby オブジェクト...

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

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

@see Proc#<<, Proc#>...

Array#<<(obj) -> self (18149.0)

指定された obj を自身の末尾に破壊的に追加します。

...ます。

//emlist[例][ruby]{
ary = [1]
ary << 2
p
ary # [1, 2]
//}

またこのメソッドは self を返すので、以下のように連続して
書くことができます。

//emlist[例][ruby]{
ary = [1]
ary << 2 << 3 << 4
p
ary #=> [1, 2, 3, 4]
//}

@param obj 自身に加えた...
...いオブジェクトを指定します。Array#push と違って引数は一つしか指定できません。

@see Array#push...

絞り込み条件を変える

Enumerator::Yielder#<<(object) -> () (18143.0)

Enumerator.new で使うメソッドです。

...が実行され、
ブロック内の << が呼ばれるたびに each に渡されたブロックが
<<
に渡された値とともに繰り返されます。

//emlist[例][ruby]{
enum = Enumerator.new do |y|
y << 1
y << 2
y << 3
end

enum.each do |v|
p
v
end
# => 1
# 2
# 3
//}...
...クが実行され、
ブロック内の << が呼ばれるたびに each に渡されたブロックが
<<
に渡された値とともに繰り返されます。

//emlist[例][ruby]{
enum = Enumerator.new do |y|
y << 1
y << 2
y << 3
end

enum.each do |v|
p
v
end
# => 1
# 2
# 3
//}...

String#<<(other) -> self (18141.0)

self に文字列 other を破壊的に連結します。 other が 整数である場合は other.chr(self.encoding) 相当の文字を末尾に追加します。

...加します。

self を返します。

@param other 文字列もしくは 0 以上の整数

//emlist[例][ruby]{
str = "string"
str.concat "XXX"
p
str # => "stringXXX"

str << "YYY"
p
str # => "stringXXXYYY"

str << 65 # 文字AのASCIIコード
p
str # => "stringXXXYYYA"
//}...
...追加します。

self を返します。

@param other 文字列もしくは 0 以上の整数

//emlist[例][ruby]{
str = "string"
str.concat "XXX"
p
str # => "stringXXX"

str << "YYY"
p
str # => "stringXXXYYY"

str << 65 # 文字AのASCIIコード
p
str # => "stringXXXYYYA"
//}...

Set#<<(o) -> self (18131.0)

集合にオブジェクト o を加えます。

...します。<< は add の別名です。

add? は、集合に要素が追加された場合には self を、変化がなかった場合には
nil を返します。

@param o 追加対象のオブジェクトを指定します。

//emlist[][ruby]{
require 'set'
s = Set[1, 2]
s << 10
p
s...
...# => #<Set: {1, 2, 10}>
p
s.add?(20) # => #<Set: {1, 2, 10, 20}>
p
s.add?(2) # => nil
//}...
...を返します。<< は add の別名です。

add? は、集合に要素が追加された場合には self を、変化がなかった場合には
nil を返します。

@param o 追加対象のオブジェクトを指定します。

//emlist[][ruby]{
s = Set[1, 2]
s << 10
p
s # =>...
...#<Set: {1, 2, 10}>
p s.add?(20) # => #<Set: {1, 2, 10, 20}>
p
s.add?(2) # => nil
//}...

Integer#<<(bits) -> Integer (18125.0)

シフト演算子。bits だけビットを左にシフトします。

...シフト演算子。bits だけビットを左にシフトします。

@param bits シフトさせるビット数

//emlist[][ruby]{
p
rintf("%#b\n", 0b0101 << 1) # => 0b1010
p
-1 << 1 # => -2
//}...

Array#repeated_permutation(n) -> Enumerator (12220.0)

サイズ n の重複順列をすべて生成し,それを引数としてブロックを実行します。

...オブジェクトを返します。

@param n 生成する配列のサイズを整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を試みます。

@raise TypeError 引数に整数以外の(暗黙...
...mlist[例][ruby]{
a = [1, 2]
a.repeated_permutation(1).to_a #=> [[1], [2]]
a.repeated_permutation(2).to_a #=> [[1,1],[1,2],[2,1],[2,2]]
a.repeated_permutation(3).to_a #=> [[1,1,1],[1,1,2],[1,2,1],[1,2,2],
# [2,1,1],[2,1,2],[2,2,1],[2,2,2]]
a.repeated_permutation...
...0).to_a #=> [[]] # one permutation of length 0
//}

ブロックが与えられた場合、作成した配列の各要素を引数としてブロックを実
行して self を返します。

//emlist[例][ruby]{
a = [1, 2]
result = []
a.repeated_permutation(3) {|e| result << e} # => [1,2]
result...

絞り込み条件を変える

<< 1 2 3 ... > >>