るりまサーチ

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

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 > >>

TrueClass#to_s -> String (35135.0)

常に文字列 "true" を返します。

...常に文字列 "true" を返します。

//emlist[例][ruby]{
true
.to_s # => "true"
//}...

Proc#to_s -> String (23113.0)

self の文字列表現を返します。

...self の文字列表現を返します。

可能なら self を生成したソースファイル名、行番号を含みます。

//emlist[例][ruby]{
p Proc.new {
true

}.to_s

# => "#<Proc:0x0x401a880c@-:3>"
//}...

Symbol#to_s -> String (23107.0)

シンボルに対応する文字列を返します。

...シンボルに対応する文字列を返します。

逆に、文字列に対応するシンボルを得るには
String#intern を使います。

p :foo.id2name # => "foo"
p :foo.id2name.intern == :foo # => true

@see String#intern...
...シンボルに対応する文字列を返します。

逆に、文字列に対応するシンボルを得るには
String#intern を使います。

p :foo.id2name # => "foo"
p :foo.id2name.intern == :foo # => true

@see String#intern
@see Symbol#name...

String#to_sym -> Symbol (11118.0)

文字列に対応するシンボル値 Symbol を返します。

...応する文字列を得るには
Symbol#to_s または Symbol#id2name を使います。

シンボル文字列にはヌルキャラクタ("\0")、空の文字列の使用も可能です。

//emlist[例][ruby]{
p "foo".intern # => :foo
p "foo".intern.to_s == "foo" # => true
//}...

Symbol#start_with?(*prefixes) -> bool (8046.0)

self の先頭が prefixes のいずれかであるとき true を返します。

...であるとき true を返します。

(self.to_s.start_with?と同じです。)

@param prefixes パターンを表す文字列または正規表現 (のリスト)

@see Symbol#end_with?

@see String#start_with?

//emlist[][ruby]{
:hello.start_with?("hell") #=> true
:hello.start_wit...
...h?(/H/i) #=> true

# returns true if one of the prefixes matches.
:hello.start_with?("heaven", "hell") #=> true
:hello.start_with?("heaven", "paradise") #=> false
//}...

絞り込み条件を変える

Symbol#end_with?(*suffixes) -> bool (8040.0)

self の末尾が suffixes のいずれかであるとき true を返します。

...れかであるとき true を返します。

(self.to_s.end_with?と同じです。)

@param suffixes パターンを表す文字列 (のリスト)

@see Symbol#start_with?

@see String#end_with?

//emlist[][ruby]{
:hello.end_with?("ello") #=> true

# returns true if one of the +suff...
...ixes+ matches.
:hello.end_with?("heaven", "ello") #=> true
:hello.end_with?("heaven", "paradise") #=> false
//}...

Symbol#name -> String (8030.0)

シンボルに対応する文字列を返します。

...シンボルに対応する文字列を返します。

Symbol#to_sと違って freeze された文字列を返します。

//emlist[][ruby]{
p :fred.name # => "fred"
p :fred.name.frozen? # => true
p :fred.to_s # => "fred"
p :fred.to_s.frozen? # => false
//}

@see Symbol#to_s...

Symbol (8024.0)

シンボルを表すクラス。シンボルは任意の文字列と一対一に対応するオブジェクトです。

...い、immutable (変更不可)であり、同値ならば必ず同一です。

p "abc" == "abc" #=> true
p "abc".equal?("abc") #=> false
p :abc == :abc #=> true
p :abc.equal?(:abc) #=> true ←同値ならば同一

==== 用途
実用面では、シンボルは文字の意味を明確にし...
..."value" }
* アクセサの引数で渡すインスタンス変数名 attr_reader :name
* メソッド引数で渡すメソッド名 __send__ :to_s
* C の enum 的な使用 (値そのものは無視してよい場合)

シンボルを使うメリットは

* 新しく文字列を生成し...

Range.new(first, last, exclude_end = false) -> Range (8018.0)

first から last までの範囲オブジェクトを生成して返しま す。

...nil の場合に発生します

//emlist[例: 整数の範囲オブジェクトの場合][ruby]{
Range.new(1, 10) # => 1..10
Range.new(1, 10, true) # => 1...10
//}

//emlist[例: 日付オブジェクトの範囲オブジェクトの場合][ruby]{
require 'date'
Range.new(Date.today, Date.tod...
...のオブジェクトの場合][ruby]{
MyInteger = Struct.new(:value) do
def succ
self.class.new(value + 1)
end

def <=>(other)
value <=> other.value
end

def to_s
value.to_s
end
end
Range.new(MyInteger.new(1), MyInteger.new(3)).each {|i| puts i }
# => 1
# 2
# 3
//}...

String#intern -> Symbol (8018.0)

文字列に対応するシンボル値 Symbol を返します。

...応する文字列を得るには
Symbol#to_s または Symbol#id2name を使います。

シンボル文字列にはヌルキャラクタ("\0")、空の文字列の使用も可能です。

//emlist[例][ruby]{
p "foo".intern # => :foo
p "foo".intern.to_s == "foo" # => true
//}...

絞り込み条件を変える

Proc#inspect -> String (8013.0)

self の文字列表現を返します。

...self の文字列表現を返します。

可能なら self を生成したソースファイル名、行番号を含みます。

//emlist[例][ruby]{
p Proc.new {
true

}.to_s

# => "#<Proc:0x0x401a880c@-:3>"
//}...
<< 1 2 > >>