るりまサーチ

最速Rubyリファレンスマニュアル検索!
200件ヒット [1-100件を表示] (0.061秒)
トップページ > クエリ:@[x] > 種類:文書[x]

検索結果

<< 1 2 > >>

ruby 1.8.4 feature (409.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...
...puts :"@1".inspect
puts :"@@1".inspect
puts :"@".inspect
puts :"@@".inspect

# => ruby 1.8.3 (2005-09-21) [i686-linux]
:!
:=
:0
:$1
:@1
:@@1...
...ェットク
ラスのサンプル兼ライブラリ

#Wed Dec 7 01:02:04 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
#
# * ext/tk/README.macosx-aqua: [new document] tips to avoid the known
# bug on platform specific dialogs of Tcl/Tk Aqua on MacOS X.

MacOS X 上で...

クラス/メソッドの定義 (61.0)

クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined

...@x, @yに対応するゲッタとセッタを定義
def initialize(x, y) # コンストラクタ
@
x = x; @y = y # @がつくのがインスタンス変数(メンバ変数)
end
def ==(other_vec) # いわゆる演算子オーバーライド
other_vec.x == @x && other_vec.y == @...
...y
end
def +(other_vec)
Vector2D.new(other_vec.x + @x, other_vec.y + @y)
end
# ...
end
vec0 = Vector2D.new(10, 20); vec1 = Vector2D.new(20, 30)
p vec0 + vec1 == Vector2D.new(30, 50) #=> true
//}

仮引数にデフォルト式が与えられた場合、メソッド呼び出しで実引数...
...# rest: ["foo", "bar", "baz"]
# x: "x"
# y: "y"
# z: "z"
# k: 42
# kwrest: {:u=>"unknown"}
# blk: #<Proc:0x007f7e7d8dd6c0@-:16>
//}

//emlist[例: イテレータの定義][ruby]{
# yield を使う
def foo
# block_given? は、メソッドがブロックを渡されて...

演算子式 (61.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] =...
...て、
識別子= というメソッドを、式 2 を引数にして呼び出します。

//emlist[例][ruby]{
class C
def foo
@
foo
end
def foo=( v )
@
foo = v
end
end
c = C.new
c.foo = 5 # c.foo=( 5 ) のように変換される
p c.foo # => 5
//}

属性は Module#attr...

ruby 1.6 feature (55.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]

:...
...わることはなくなりました。((<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....
...variable

((<ruby-talk:35122>))

class C
class << self
def test
@
@cv = 5
p @@cv
end
end

test
end
=> -:5:in `test': uninitialized class variable @@cv in C (NameError)
from -:9
ruby 1.6.7 (2002-03-01) [i586-linux]...

Marshal フォーマット (43.0)

Marshal フォーマット フォーマットバージョン 4.8 を元に記述しています。

...lass Foo < Array # (or String, Regexp, Hash)
def initialize(obj)
@
foo = false
super(obj)
end
end
p Marshal.dump(Foo.new([true])).unpack("x2 a a a c a3 aca caca4 a")
# => ["I", "C", ":", 8, "Foo", "[", 6, "T", 6, ":", 9, "@foo", "F"]
//}

==== その他

実装上内部構造が異なる...
...タンス変数あり][ruby]{
class Foo
def initialize
@
foo = :bar
@
one = 1
end
end
p Marshal.dump(Foo.new).unpack("x2 a a c a3 c aca4 aca3 aca4 ac")
# => ["o", ":", 8, "Foo", 7,
# ":", 9, "@foo", ":", 8, "bar",
# ":", 9, "@one", "i", 6]
//}

=== Float

'f' で始まるデータ...
...cii-8bit
p Marshal.dump("hogehoge").unpack("x2 a c a*")
# => ["\"", 13, "hogehoge"]
//}

ruby 1.9.0 以降では encoding が 'encoding' という
@」のつかない内部的なインスタンス変数としてダンプされます。

//emlist[例: euc-jp の時][ruby]{
p Marshal.dump("hogehoge...

絞り込み条件を変える

パターンマッチ (37.0)

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

...//emlist[][ruby]{
class Point
def initialize(x, y)
@
x, @y = x, y
end

def deconstruct
puts "deconstruct called"
[@x, @y]
end

def deconstruct_keys(keys)
puts "deconstruct_keys called with #{keys.inspect}"
{x: @x, y: @y}
end
end

case Point.new(1, -2)
in px, Integer...
...ーバル変数、クラス変数に対してもピン演算子は利用できます。

//emlist{
$gvar = 1
class A
@
ivar = 2
@
@cvar = 3
case [1, 2, 3]
in ^$gvar, ^@ivar, ^@@cvar
"matched"
else
"not matched"
end
#=> "matched"
end
//}

また、括弧を使って任意の式に...

pack テンプレート文字列 (25.0)

pack テンプレート文字列

...jZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWg==".unpack("m0")
# => ["abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"]
//}
@
see base64

: M

quoted-printable encoding された文字列
//emlist[][ruby]{
["a b c\td \ne"].pack("M") # => "a b c\td =\n\ne=\n"

"a b c\td =\n...
...inity
[-1.0/0.0].pack("f") # => "\xFF\x80\x00\x00" # -Infinity
//}

VAX (NetBSD 3.0) (非IEEE754):
//emlist[][ruby]{
[1.0].pack("f") # => "\x80@\x00\x00"
//}

: d

倍精度浮動小数点数(機種依存)

x86_64 (IEEE754 倍精度 リトルエンディアン):
//emlist[][ruby]{
[1.0].pa...
....pack("d") # => "\xFF\xF0\x00\x00\x00\x00\x00\x00" # -Infinity
//}

VAX (NetBSD 3.0) (非IEEE754):
//emlist[][ruby]{
[1.0].pack("d") # => "\x80@\x00\x00\x00\x00\x00\x00"
//}

: e

リトルエンディアンの単精度浮動小数点数(機種依存)

x86_64 (IEEE754):
//emlist[][ruby]{...

1.6.8から1.8.0への変更点(まとめ) (13.0)

1.6.8から1.8.0への変更点(まとめ) * ((<1.6.8から1.8.0への変更点(まとめ)/インタプリタの変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたクラス/モジュール>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたメソッド>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加された定数>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張されたクラス/メソッド(互換性のある変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/変更されたクラス/メソッド(互換性のない変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/文法の変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/正規表現>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Marshal>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Windows 対応>)) * ((<1.6.8から1.8.0への変更点(まとめ)/廃止された(される予定の)機能>)) * ((<1.6.8から1.8.0への変更点(まとめ)/ライブラリ>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張ライブラリAPI>)) * ((<1.6.8から1.8.0への変更点(まとめ)/バグ修正>)) * ((<1.6.8から1.8.0への変更点(まとめ)/サポートプラットフォームの追加>))

...することにより定数参照の速度を改善したそうです。
(ChangeLogの
Tue Jun 5 16:15:58 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
に該当するようです)

: break and next [compat]

break, next は、引数を指定することでイテレータや y...
...ました。
((<ruby-dev:18278>))

local ||= 1
@
instance ||= 1
$global ||= 1
@
@class ||= 1

=> -:3: warning: global variable `$global' not initialized
-:4: uninitialized class variable @@class in Object (NameError)
ruby 1.6.7 (2002-03-0...

NEWS for Ruby 3.0.0 (13.0)

NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...rue` is used. 17104
* Magic comment `shareable_constant_value` added to freeze constants.
See {Magic Comments}[rdoc-ref:doc/syntax/comments.rdoc@Magic+Comments] for more details.
17273
* A {static analysis}[rdoc-label:label-Static+analysis] foundation is
introduced.
* {RBS}[rdo...
...on uses only methods ending with `!`.
* Ractor compatible.
* Improved support for YAML. 8382
* Use officially discouraged. Read OpenStruct@Caveats section.
* Pathname
* Ractor compatible.
* Psych
* Update to Psych 3.3.0
* This version is Ractor compatible.
* Reline...
...ses like Hash and their subclasses.
* Method inlining support for some C methods
* `Kernel`: `#class`, `#frozen?`
* `Integer`: `#-@`, `#~`, `#abs`, `#bit_length`, `#even?`, `#integer?`, `#magnitude`, `#odd?`, `#ord`, `#to_i`, `#to_int`, `#zero?`
* `Struct`: reader methods...
<< 1 2 > >>