るりまサーチ

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

別のキーワード

  1. _builtin ^
  2. set ^
  3. integer ^
  4. nilclass ^
  5. trueclass ^

検索結果

<< 1 2 3 > >>

FalseClass#^(other) -> bool (18148.0)

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 (18148.0)

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

...

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

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

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

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

NilClass#^(other) -> bool (18130.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 (18118.0)

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

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

@
param other 数値

1 ^ 1 #=> 0
2 ^ 3 #=> 1...

Fixnum#^(other) -> Fixnum | Bignum (18118.0)

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

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

@
param other 数値

1 ^ 1 #=> 0
2 ^ 3 #=> 1...

絞り込み条件を変える

Integer#^(other) -> Integer (18118.0)

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

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

@
param other 数値

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

Set#^(enum) -> Set (18118.0)

対称差、すなわち、2 つの集合のいずれか一方にだけ属するすべての要素からなる 新しい集合を作ります。

...す。

@
param enum each メソッドが定義されたオブジェクトを指定します。
@
raise ArgumentError 引数 enum に each メソッドが定義されていない場合に
発生します。

//emlist[][ruby]{
require 'set'
s1 = Set[10, 20, 30]
s2 = Set[10, 30, 50]
p s1 ^ s2 # =...
...ります。

@
param enum each メソッドが定義されたオブジェクトを指定します。
@
raise ArgumentError 引数 enum に each メソッドが定義されていない場合に
発生します。

//emlist[][ruby]{
s1 = Set[10, 20, 30]
s2 = Set[10, 30, 50]
p s1 ^ s2 # => #<Set:...

ruby 1.8.4 feature (414.0)

ruby 1.8.4 feature ruby 1.8.4 での ruby 1.8.3 からの変更点です。

...# => ruby 1.8.4 (2005-12-16) [i686-linux]
-:1: empty symbol literal

: Symbol [bug]

#Sat Oct 22 13:26:57 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
#
# * object.c (sym_inspect), parse.y (parser_yylex, rb_symname_p): check
# if valid as a symbol name more strictly. [r...
...8.4 (2005-12-22) [i686-linux]
-:2: syntax error, unexpected tSTRING_CONTENT
alias :"foo" :"bar"
^

-:2: warning: unused literal ignored
# => ruby 1.9.0 (2005-12-10) [i686-linux]
"bar"...
...puts :"@1".inspect
puts :"@@1".inspect
puts :"@".inspect
puts :"@@".inspect

# => ruby 1.8.3 (2005-09-21) [i686-linux]
:!
:=
:0
:$1
:@1
:@@1...

ruby 1.6 feature (84.0)

ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。

...>))

Object.new.instance_eval {
p remove_instance_variable :@foo
}
=> ruby 1.6.7 (2002-03-01) [i586-linux]
nil

=> -:2:in `remove_instance_variable': instance variable @foo not defined (NameError)
ruby 1.6.7 (2002-04-10) [i586-linux]

:...
....7 (2002-03-01) [i586-linux]
#<MatchData:0x401b1be4>
-:3: wrong argument type nil (expected Match) (TypeError)
^
^^^^ MatchData の間違い
=> ruby 1.6.7 (2002-04-04) [i586-linux]
#<MatchData:0x401b1c98>
nil

: 2002-03-25...
...わることはなくなりました。((<ruby-dev:17876>))

class Foo
FOO = 1
@
@foo = 1
end

FOO = 2
@
@foo = 2

Foo.module_eval { p FOO, @@foo }

=> ruby 1.6.7 (2002-03-01) [i586-linux]
1
1

=> ruby 1....

パターンマッチ (78.0)

パターンマッチ * patterns * variable_binding * variable_pinning * matching_non_primitive_objects * guard_clauses * current_feature_status * pattern_syntax * some_undefined_behavior_examples

...ターンの部品として利用するよ」ということを伝えるためにピン演算子 『^』 を利用することができます。

//emlist[][ruby]{
expectation = 18
case [1, 2]
in ^expectation, *rest
"matched. expectation was: #{expectation}"
else
"not matched. expectation was: #...
...{id:, level: ^school}] # select the last school, level should match
"matched. school: #{id}"
else
"not matched"
end
#=> "matched. school: 2"

case john # 指定された school の level は "high" だが、最後の school はマッチしない
in school:, schools: [*, {id:, level: ^school}]...
...$gvar = 1
class A
@
ivar = 2
@
@cvar = 3
case [1, 2, 3]
in ^$gvar, ^@ivar, ^@@cvar
"matched"
else
"not matched"
end
#=> "matched"
end
//}

また、括弧を使って任意の式に対してピン演算子を利用できます

//emlist{
a = 1
b = 2
case 3
in ^(a + b)
"matched...

絞り込み条件を変える

演算子式 (72.0)

演算子式 * assign * selfassign * multiassign * range * range_cond * and * or * not * cond

...**
-(単項)
* / %
+ -
<< >>
&
| ^
> >= < <=
<=> == === != =~ !~
&&
||
.. ......
...定義できる演算子(メソッド)

+@, -@ は単項演算子 +, - を表しメソッド定義
などではこの記法を利用します。


//emlist{
| ^ & <=> == === =~ > >= < <= << >>
+ - * / % ** ~ +@ -@ [] []= ` ! != !~
//}
これらの演算...
...る []= メソッド呼び出しに変換されます。

//emlist[例][ruby]{
class C
def initialize
@
ary = [0,1,2,3,4,5,6,7]
end
def [](i)
@
ary[i * 2]
end
def []=( i, v )
@
ary[i * 2] = v
end
end
c = C.new
p c[3] # c.[]( 3 ) に変換され、その結果は 6
p c[3] =...
<< 1 2 3 > >>