るりまサーチ

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

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

クラス

モジュール

オブジェクト

キーワード

検索結果

<< 1 2 3 ... > >>

Integer#|(other) -> Integer (29314.0)

ビット二項演算子。論理和を計算します。

...ビット二項演算子。論理和を計算します。

@param other 数値

//emlist[][ruby]{
1 | 1 # => 1
2 | 3 # => 3
//}...

FalseClass#|(other) -> bool (29244.0)

other が真なら true を, 偽なら false を返します。

...other が真なら true を, 偽なら false を返します。

@param other 論理和を行なう式です。

|
は再定義可能な演算子に分類されていますので、通常は false | other の形で使われます。

//emlist[例][ruby]{
p false | true #=> true
p false | false...
...#=> false
p false | nil #=> false
p false | (1 == 1) #=> true
p false | (1 + 1) #=> true

p false.|(true) #=> true
p false.|(false) #=> false
p false.|(nil) #=> false
p false.|(1 == 1) #=> true
p false.|(1 + 1) #=> true
//}...

TrueClass#|(other) -> bool (29244.0)

常に true を返します。

...true を返します。

@param other 論理和を行なう式です。

|
は再定義可能な演算子に分類されていますので、通常は true | other のように使われます。

//emlist[例][ruby]{
p true | true #=> true
p true | false #=> true
p true | nil #=> true
p...
...true | (1 == 1) #=> true
p true | (1 + 1) #=> true

p true.|(true) #=> true
p true.|(false) #=> true
p true.|(nil) #=> true
p true.|(1 == 1) #=> true
p true.|(1 + 1) #=> true
//}...

NilClass#|(other) -> bool (26226.0)

other が真なら true を, 偽なら false を返します。

...other が真なら true を, 偽なら false を返します。

@param other 論理和を行なう式です

//emlist[例][ruby]{
nil | true # => true
nil | false # => false
nil | nil # => false
nil | "a" # => true
//}...

Bignum#|(other) -> Fixnum | Bignum (26215.0)

ビット二項演算子。論理和を計算します。

...ビット二項演算子。論理和を計算します。

@param other 数値

1 | 1 #=> 1
2 | 3 #=> 3...

絞り込み条件を変える

Fixnum#|(other) -> Fixnum | Bignum (26215.0)

ビット二項演算子。論理和を計算します。

...ビット二項演算子。論理和を計算します。

@param other 数値

1 | 1 #=> 1
2 | 3 #=> 3...

Array#|(other) -> Array (26208.0)

集合の和演算です。両方の配列にいずれかに含まれる要素を全て含む新し い配列を返します。重複する要素は取り除かれます。

...する要素は取り除かれます。

要素の重複判定は、Object#eql? と Object#hash により行われます。

新しい配列における要素の順は self における要素の順と同じです。

@param other 配列を指定します。
配列以外のオブジェ...
...る暗黙の型変換を試みます。

@raise TypeError 引数に配列以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。

//emlist[例][ruby]{
[1, 1, 4, 2, 3] | [5, 4, 5] #=> [1, 4, 2, 3, 5]
//}

@see Array#&...
...暗黙の型変換を試みます。

@raise TypeError 引数に配列以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。

//emlist[例][ruby]{
[1, 1, 4, 2, 3] | [5, 4, 5] #=> [1, 4, 2, 3, 5]
//}

@see Array#&
@see Array#union...

Enumerator::ArithmeticSequence#end -> Numeric | nil (20203.0)

末項(終端)を返します。

...末項(終端)を返します。

@see Enumerator::ArithmeticSequence#begin...

Encoding::Converter.asciicompat_encoding(encoding) -> Encoding | nil (17404.0)

同じ文字集合を持つ ASCII 互換エンコーディングを返します。

...集合を持つ ASCII 互換エンコーディングを返します。

@param string エンコーディング名
@param encoding エンコーディングオブジェクト
@return ASCII 互換エンコーディングのオブジェクトか nil

引数とエンコーディングと同じ文字集...
...ングでない場合は nil を返します。

//emlist[][ruby]{
E
ncoding::Converter.asciicompat_encoding("ISO-2022-JP") #=> #<Encoding:stateless-ISO-2022-JP>
E
ncoding::Converter.asciicompat_encoding("UTF-16BE") #=> #<Encoding:UTF-8>
E
ncoding::Converter.asciicompat_encoding("UTF-8") #=> nil
//}...

Object#yield_self {|x| ... } -> object (17328.0)

self を引数としてブロックを評価し、ブロックの結果を返します。

...self を引数としてブロックを評価し、ブロックの結果を返します。

//emlist[例][ruby]{
"my string".yield_self {|s| s.upcase } # => "MY STRING"
3.next.yield_self {|x| x**x }.to_s # => "256"
//}

値をメソッドチェインのパイプラインに次々と渡すの...
...方です。

//emlist[メソッドチェインのパイプライン][ruby]{
require 'open-uri'
require 'json'

construct_url(arguments).
yield_self {|url| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}

ブロックなしで呼び出されたときは Enumerator を返しま...
...す。
例えば条件によって値を捨てるのに使えます。

//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}

@see Object#tap...
...self を引数としてブロックを評価し、ブロックの結果を返します。

//emlist[例][ruby]{
3.next.then {|x| x**x }.to_s # => "256"
"my string".yield_self {|s| s.upcase } # => "MY STRING"
//}

値をメソッドチェインのパイプラインに次々と渡すの...

絞り込み条件を変える

Enumerator::Lazy#enum_for(method = :each, *args) {|*args| block} -> Enumerator::Lazy (17322.0)

Object#to_enum と同じですが、Enumerator::Lazy を返します。

...Object#to_enum と同じですが、Enumerator::Lazy を返します。

to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
E
numerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が...
...o_enum は
素のEnumerator ではなく Enumerator::Lazy を返すようになっています。

//emlist[例][ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) #=> [1,1,2,2,3,3]
def repeat(n)
raise ArgumentError if n < 0
if block_given...
...do |*val|
n.times { yield *val }
e
nd
e
lse
to_enum(:repeat, n)
e
nd
e
nd
e
nd

r = 1..10
p r.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]

r = 1..Float::INFINITY
p r.lazy.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]

# Lazy#to_enum のおかげで、repeat...

Enumerator::Lazy#to_enum(method = :each, *args) {|*args| block} -> Enumerator::Lazy (17322.0)

Object#to_enum と同じですが、Enumerator::Lazy を返します。

...Object#to_enum と同じですが、Enumerator::Lazy を返します。

to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
E
numerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が...
...o_enum は
素のEnumerator ではなく Enumerator::Lazy を返すようになっています。

//emlist[例][ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) #=> [1,1,2,2,3,3]
def repeat(n)
raise ArgumentError if n < 0
if block_given...
...do |*val|
n.times { yield *val }
e
nd
e
lse
to_enum(:repeat, n)
e
nd
e
nd
e
nd

r = 1..10
p r.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]

r = 1..Float::INFINITY
p r.lazy.map{|n| n**2}.repeat(2).first(5)
#=> [1, 1, 4, 4, 9]

# Lazy#to_enum のおかげで、repeat...
<< 1 2 3 ... > >>