るりまサーチ

最速Rubyリファレンスマニュアル検索!
42件ヒット [1-42件を表示] (0.018秒)
トップページ > クエリ:![x] > クエリ:instance_method[x]

別のキーワード

  1. csv instance
  2. prime instance
  3. syslog instance
  4. _builtin instance_eval
  5. singleton instance

ライブラリ

クラス

検索結果

Module#instance_method(name) -> UnboundMethod (18137.0)

self のインスタンスメソッド name をオブジェクト化した UnboundMethod を返します。

...#public_instance_method, Object#method

//emlist[例][ruby]{
class Interpreter
def do_a() print "there, "; end
def do_d() print "Hello "; end
def do_e() print "!\n"; end
def do_v() print "Dave"; end
Dispatcher = {
"a" => instance_method(:do_a),
"d" => instance_method(:do_d)...
...,
"e" => instance_method(:do_e),
"v" => instance_method(:do_v)
}
def interpret(string)
string.each_char {|b| Dispatcher[b].bind(self).call }
end
end

interpreter = Interpreter.new
interpreter.interpret('dave')
# => Hello there, Dave!
//}...

ruby 1.6 feature (78.0)

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

...)

: 2002-07-11 String#slice!

範囲外の文字列を指定したときに例外を返す場合がありましたが、常に nil
を返すようになりました。(String#[]やString#slice と同じ結果を返すと
いうことです)

p "foo".slice!("bar") # <- 以前から...
...こちらは nil を返していた
p "foo".slice!(5,10)

=> ruby 1.6.7 (2002-03-01) [i586-linux]
nil
-:2:in `slice!': index 5 out of string (IndexError)
from -:2
=> ruby 1.6.7 (2002-08-01) [i586-linux]
nil
nil

: 20...
...((<ruby-dev:14942>))

Module.constants.each {|c|
c = eval c
if c.instance_of?(Class)
p c
c.instance_methods.each {|m|
c.module_eval "undef #{m};"
}
c.module_eval {undef initialize}
end
}...

NEWS for Ruby 2.7.0 (30.0)

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

...by 3.0 では verbose モードでなくても表示され、Ruby 3.2 で削除される
予定です。 16131

* Object#methodとModule#instance_methodがrefinementsを考慮するようになりました。 15373

=== コマンドラインオプション

==== 警告オプション

カテ...
...を止める例:

//emlist{
$ ruby -e '0 in a'
-e:1: warning: Pattern matching is experimental, and the behavior may change in future versions of Ruby!

$ ruby -W:no-experimental -e '0 in a'
//}

* RUBYOPTで両方止めるにはスペース区切りで指定します:

//emlist{
$ RUBYOPT='-W:no-...
...st[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.with_index(1) { |it, index| puts...

ruby 1.8.4 feature (18.0)

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

...!".inspect
puts :"=".inspect
puts :"0".inspect
puts :"$1".inspect
puts :"@1".inspect
puts :"@@1".inspect
puts :"@".inspect
puts :"@@".inspect

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

3) Symbol#inspect sometimes returns suboptimal symbol representations:
puts :foo!.inspect...
...def initialize
super
end
end

class Bar
include Foo
def initialize
Foo.instance_method(:initialize).bind(self).call
end
end

Bar.new

# => ruby 1.8.3 (2005-09-21) [i686-linux]
-:3:i...