るりまサーチ

最速Rubyリファレンスマニュアル検索!
24件ヒット [1-24件を表示] (0.079秒)
トップページ > クエリ:string[x] > クエリ:Ruby[x] > クエリ:ruby[x] > クエリ:String[x] > 種類:インスタンスメソッド[x] > クエリ:@[x] > クエリ:puts[x] > クラス:Object[x]

別のキーワード

  1. string []=
  2. string slice!
  3. string slice
  4. string []
  5. string gsub!

ライブラリ

キーワード

検索結果

Object#to_s -> String (252.0)

オブジェクトの文字列表現を返します。

...使って文字列に変換し
ます。

//emlist[][ruby]{
class Foo
def initialize num
@
num = num
end
end
it = Foo.new(40)

puts
it #=> #<Foo:0x2b69110>

class Foo
def to_s
"Class:Foo Number:#{@num}"
end
end

puts
it #=> Class:Foo Number:40
//}

@
see Object#to_str,Kernel.#String...

Object#===(other) -> bool (134.0)

case 式で使用されるメソッドです。d:spec/control#case も参照してください。

...ルトでは内部で Object#== を呼び出します。

when 節の式をレシーバーとして === を呼び出すことに注意してください。

また Enumerable#grep でも使用されます。

@
param other 比較するオブジェクトです。

//emlist[][ruby]{
age = 12
# (0..2).=...
...lt"
end

puts
result #=> "child"

def check arg
case arg
when /ruby(?!\s*on\s*rails)/i
"hit! #{arg}"
when String
"Instance of String class. But don't hit."
else
"unknown"
end
end

puts
check([]) #=> unknown
puts
check("mash-up in Ruby on Rails") #=> instance of String class....
...But not hit...
puts
check("<Ruby's world>") #=> hit! <Ruby's world>
//}

@
see Object#==, Range#===, Module#===, Regexp#===, Enumerable#grep...