種類
- 文書 (66)
- インスタンスメソッド (36)
ライブラリ
- ビルトイン (36)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) -
NEWS for Ruby 2
. 3 . 0 (10) -
NEWS for Ruby 2
. 4 . 0 (9) -
NEWS for Ruby 2
. 7 . 0 (6) -
NEWS for Ruby 3
. 0 . 0 (5) - lambda? (12)
-
ruby 1
. 9 feature (12) - メソッド呼び出し(super・ブロック付き・yield) (12)
検索結果
先頭5件
-
Method
# to _ proc -> Proc (18113.0) -
self を call する Proc オブジェクトを生成して返します。
...self を call する Proc オブジェクトを生成して返します。
//emlist[例][ruby]{
class Foo
def foo
"foo"
end
end
m = Foo.new.method(:foo) # => #<Method: Foo#foo>
pr = m.to_proc # => #<Proc:0x007f874d026008 (lambda)>
pr.call # => "foo"
//}... -
Object
# to _ proc -> Proc (18113.0) -
オブジェクトの Proc への暗黙の変換が必要なときに内部で呼ばれます。 デフォルトでは定義されていません。
...すが、
このメソッドは実際には Object クラスには定義されていません。
必要に応じてサブクラスで定義すべきものです。
//emlist[][ruby]{
def doing
yield
end
class Foo
def to_proc
Proc.new{p 'ok'}
end
end
it = Foo.new
doing(&it) #=> "ok"
//}... -
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (312.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への変更点(まとめ)/サポートプラットフォームの追加>))
...よくわかりません(^^;
class << Object
p [self.id, self]
class << self
p [self.id, self]
end
end
=> ruby 1.6.7 (2002-03-01) [i586-linux]
[537771634, Class]
[537742484, Class]
=> ruby 1.7.3 (2002-09......-05) [i586-linux]
[537771634, #<Class:Object>]
[537771634, #<Class:Object>]
さらに、オブジェクトの特異クラスのスーパークラスの特異クラスと
オブジェクトの特異クラスの特異クラスのスーパークラスは同じなのだそう......ッド引数の & 修飾|メソッド呼び出し/イテレータ>)) [compat]
: ((<Proc#to_proc|Proc/to_proc>)) [new]
メソッドに渡す引数に & を修飾した場合、渡すオブジェクトが to_proc を
持っていればそれを実行し、その結果をブロックとして渡... -
NEWS for Ruby 3
. 0 . 0 (96.0) -
NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...d in singleton class definitions in methods is now a SyntaxError
instead of a warning. yield in a class definition outside of a method
is now a SyntaxError instead of a LocalJumpError. 15575
* When a class variable is overtaken by the same definition in an
ancestor class/module, a Run......timeError is now raised (previously,
it only issued a warning in verbose mode). Additionally, accessing a
class variable from the toplevel scope is now a RuntimeError.
14541
* Assigning to a numbered parameter is now a SyntaxError instead of
a warning.
== Command line options
==......#sub
* String#succ / String#next
* String#swapcase
* String#tr
* String#tr_s
* String#upcase
* Symbol
* Symbol#to_proc now returns a lambda Proc. 16260
* Symbol#name has been added, which returns the name of the symbol if it is named. The returned string is... -
メソッド呼び出し(super・ブロック付き・yield) (54.0)
-
メソッド呼び出し(super・ブロック付き・yield) * super * block * yield * block_arg * numbered_parameters * call_method
...lock
* yield
* block_arg
* numbered_parameters
* call_method
//emlist[例][ruby]{
foo.bar()
foo.bar
bar()
print "hello world\n"
print
Class.new
Class::new
//}
文法:
[式 `.'] 識別子 [`(' [[`*'] 式] ... [`&' 式] `)']
[式 `::'] 識別子 [`(' [[`*'] 式] ... [`&......オーバーライドしたメソッドを呼び出すには
super() と括弧を明示します。
//emlist[例][ruby]{
class Foo
def foo(arg=nil)
p arg
end
end
class Bar < Foo
def foo(arg)
super(5) # 5 を引数にして呼び出す
super(arg) # 5 を引数にして......ている
# => 1
# 2
# 3
//}
to_proc メソッドを持つオブジェクトならば、`&'
修飾した引数として渡すことができます。デフォルトで Proc、Method オブジェ
クトは共に to_proc メソッドを持ちます。to_proc はメソッド呼び出し時に実... -
NEWS for Ruby 2
. 7 . 0 (42.0) -
NEWS for Ruby 2.7.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...ted です。 15575
この警告は「-W:no-deprecated」オプションで止められます。
//emlist{
def foo
class << Object.new
yield #=> warning: `yield' in class syntax will not be supported from Ruby 3.0. 15575
end
end
foo { p :ok }
//}
* 引数を転送する記法「(...)......zy ではない enumerator を生成する
Enumerator::Lazy#eagerメソッドが追加されました。 15901
* Enumerator::Yielder#to_procメソッドが追加され、Yielder オブジェクトを
直接他のメソッドのブロック引数として渡せるようになり......sday?) #=> next Tuesday
//}
//emlist[Enumerator::Lazy#eager][ruby]{
a = %w(foo bar baz)
e = a.lazy.map {|x| x.upcase }.map {|x| x + "!" }.eager
p e.class #=> Enumerator
p e.map {|x| x + "?" } #=> ["FOO!?", "BAR!?", "BAZ!?"]
//}
//emlist[Enumerator::Lazy#with_index][ruby]{
("a"..).lazy... -
Proc
# lambda? -> bool (36.0) -
手続きオブジェクトの引数の取扱が厳密であるならば true を返します。
...#=> false
# Method#to_proc によるものは lambda?が真となる
def m() end
method(:m).to_proc.lambda? #=> true
# Module#define_method は特別扱いで、
# これで定義されたメソッドの引数は常に厳密に取り扱われる
class C
define_method(:d) {}
end
C.n......ew.d(1,2) #=> ArgumentError
C.new.method(:d).to_proc.lambda? #=> true
class C
define_method(:e, &proc {})
end
C.new.e(1,2) #=> ArgumentError
C.new.method(:e).to_proc.lambda? #=> true
//}... -
ruby 1
. 9 feature (24.0) -
ruby 1.9 feature ruby version 1.9.0 は開発版です。 以下にあげる機能は将来削除されたり互換性のない仕様変更がなされるかもしれません。 1.9.1 以降は安定版です。 バグ修正がメインになります。
...削除
=== 2006-06-11
: __callee__ [new]
: __method__ [new]
((<URL:http://www.dm4lab.to/~usa/ruby/d/200606a.html#id20060610_P1_7>))
: Symbol#to_proc
=== 2006-06-10
* 新機能
: BasicObject が導入されました [new]
: local という visibility および Module#local, Module#local_m......v:28582>)), ((<ruby-talk:185438>)), ((<ruby-core:07414>))
((<URL:http://www.atdot.net/~ko1/w3ml/w3ml.cgi/ruby-cvs/msg/16833>))
((<URL:http://eigenclass.org/hiki.rb?Changes+in+Ruby+1.9+update+4>))
=== 2006-05-22
: accept
((<ruby-core:7917>))
=== 2006-03-21
: MatchData#[] [compat]
名前......なくなりました。
((<ruby-dev:25101>))
: Hash#hash [new]
追加 ((<ruby-talk:122482>))
=== 2004-12-03
: method(:y).to_proc.call{ p :ok }
Method#to_proc で作った ((<Proc>)) オブジェクトからメソッド y へと
ブロックが引き渡されるようになりました。... -
NEWS for Ruby 2
. 3 . 0 (18.0) -
NEWS for Ruby 2.3.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...sh#fetch_values を追加
10017
* Hash#dig を追加
11643
* Hash#<=, Hash#<, Hash#>=, Hash#> を追加
10984
* Hash#to_proc を追加
11653
* IO
* 新しいフラグ File::SHARE_DELETE(File::Constants::SHARE_DELETE) が使用できます。
Windows......bjectSpace (objspace)
* ObjectSpace.#count_symbols を追加。
* ObjectSpace.#count_imemo_objects を追加。
* ObjectSpace.#internal_class_of を追加。
* ObjectSpace.#internal_super_of を追加。
* OpenSSL
* OpenSSL::SSL::SSLSocket#accept_nonblock と
OpenSSL::SS......$SAFE=3 が廃止されました。$SAFE を2以上にすると ArgumentError が発生します。
5455
=== C API の更新
* rb_define_class_id_under() は既にクラスが定義済みなのに、
そのスーパークラスが与えられたスーパークラスと一致しない... -
NEWS for Ruby 2
. 4 . 0 (18.0) -
NEWS for Ruby 2.4.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...い。
== 2.3.0 以降の変更
=== 言語仕様の変更
* 条件式での多重代入ができるようになりました 10617
* Symbol#to_proc でメソッド呼び出し元での Refinements が有効になりました 9451
* Object#send や BasicObject#__send__ でメソッドを呼......た。これらを使用している場合、
コンパイルエラーになります。
//emlist{
# 0のクラスはInteger
0.class # => Integer
Fixnum # => Integer
Bignum # => Integer
# 以下の2つは同じ
obj.kind_of?(Fixnum)
obj.k......を使います */
RUBY_INTEGER_UNIFICATION
# Rubyレベルでは以下のコードでこの機能を検出できます
0.class == Integer
//}
* String/Symbol#upcase/downcase/swapcase/capitalize(!) はASCIIだけでなく全てのUnicodeに対して動作するように...