るりまサーチ

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

別のキーワード

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

ライブラリ

モジュール

オブジェクト

キーワード

検索結果

<< < 1 2 3 4 5 ... > >>

Integer#>>(bits) -> Integer (14100.0)

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

...、符号ビット(最上位ビット(MSB))が保持されます。
bitsが実数の場合、小数点以下を切り捨てた値でシフトします。

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

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

Method#>>(callable) -> Proc (14100.0)

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

...d(: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 >> met...
...hod(:pp)
pipeline.call('testfile') # => ["Hello", "World", "Hello", "Ruby"]
//}

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

Module#<=>(other) -> Integer | nil (14100.0)

self と other の継承関係を比較します。

...のクラスやモジュール

//emlist[例][ruby]{
module Foo
end
class Bar
include Foo
end
class Baz < Bar
end
class Qux
end
p Bar <=> Foo # => -1
p Baz <=> Bar # => -1
p Baz <=> Foo # => -1
p Baz <=> Qux # => nil
p Qux <=> Baz # => nil

p Baz <=> Object.new # => nil
//}...

Module#>=(other) -> bool | nil (14100.0)

比較演算子。self が other の先祖か同一クラスである場合、 true を返します。 self が other の子孫である場合、false を返します。

...ule#<

//emlist[例][ruby]{
module Foo; end
module Bar
include Foo
end
module Baz
prepend Foo
end

Bar.ancestors # => [Bar, Foo]
Foo >= Bar # => true
Bar >= Foo # => false

Baz.ancestors # => [Foo, Baz]
Foo >= Baz # => true
Baz >= Foo # => false

Foo >= Foo # => true
Foo >= Object # => nil
//}...

Numeric#<=>(other) -> -1 | 0 | 1 | nil (14100.0)

自身が other より大きい場合に 1 を、等しい場合に 0 を、小さい場合には -1 をそれぞれ返します。 自身と other が比較できない場合には nil を返します。

...Numeric のサブクラスは、上の動作を満たすよう このメソッドを適切に再定義しなければなりません。

@param other 自身と比較したい数値を指定します。

//emlist[例][ruby]{
1 <=> 0 #=> 1
1 <=> 1 #=> 0
1 <=> 2 #=> -1
1 <=> "0" #=> nil
//}...

絞り込み条件を変える

Object#<=>(other) -> 0 | nil (14100.0)

self === other である場合に 0 を返します。そうでない場合には nil を返します。

...self === other である場合に 0 を返します。そうでない場合には nil を返します。

//emlist[例][ruby]{
a = Object.new
b = Object.new
a <=> a # => 0
a <=> b # => nil
//}

@see Object#===...

Proc#>>(callable) -> Proc (14100.0)

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

...(f >> 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 = proc { |fname| File.read(fname) } >> WordScanner >>...
...method(:p)
pipeline.call('testfile') # => ["Hello", "World", "Hello", "Ruby"]
//}

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

Process::Status#>>(num) -> Integer (14100.0)

self.to_i >> num と同じです。

...self.to_i >> num と同じです。

@param num 整数を指定します。

fork { exit 99 } #=> 26563
Process.wait #=> 26563
$?.to_i #=> 25344
$? >> 8 #=> 99...

Rational#<=>(other) -> -1 | 0 | 1 | nil (14100.0)

self と other を比較して、self が大きい時に 1、等しい時に 0、小さい時に -1 を返します。比較できない場合はnilを返します。

...ます。

//emlist[例][ruby]{
Rational(2, 3) <=> Rational(2, 3) # => 0
Rational(5) <=> 5 # => 0
Rational(2, 3) <=> Rational(1,3) # => 1
Rational(1, 3) <=> 1 # => -1
Rational(1, 3) <=> 0.3 # => 1
Rational(1, 3) <=> nil # => nil
//}...

String#<=>(other) -> -1 | 0 | 1 | nil (14100.0)

self と other を ASCII コード順で比較して、 self が大きい時には 1、等しい時には 0、小さい時には -1 を返します。 このメソッドは Comparable モジュールのメソッドを実装するために使われます。

...<=> が定義されていれば
0 - (other <=> self) の結果を返します。
そうでなければ nil を返します。

@param other 文字列
@return 比較結果の整数か nil

//emlist[例][ruby]{
p "aaa" <=> "xxx" # => -1
p "aaa" <=> "aaa" # => 0
p "xxx" <=> "aaa" # =>...
...1

p "string" <=> "stringAA" # => -1
p "string" <=> "string" # => 0
p "stringAA" <=> "string" # => 1
//}...

絞り込み条件を変える

Symbol#<=>(other) -> -1 | 0 | 1 | nil (14100.0)

self と other のシンボルに対応する文字列を ASCII コード順で比較して、 self が小さい時には -1、等しい時には 0、大きい時には 1 を返します。

...er がシンボルではなく比較できない時には nil を返します。

@param other 比較対象のシンボルを指定します。

//emlist[][ruby]{
p :aaa <=> :xxx # => -1
p :aaa <=> :aaa # => 0
p :xxx <=> :aaa # => 1
p :foo <=> "foo" # => nil
//}

@see String#<=>, Symbol#casecmp...
<< < 1 2 3 4 5 ... > >>