るりまサーチ

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

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

クラス

検索結果

Hash#shift -> [object, object] | nil (18180.0)

ハッシュからキーが追加された順で先頭の要素をひとつ取り除き、 [key, value]という配列として返します。

...いう配列として返します。

shift
は破壊的メソッドです。selfは要素を取り除かれた残りのハッシュに変更されます。

Ruby
3.2以前は、ハッシュが空の場合、デフォルト値(Hash#defaultまたはHash#default_procのブロックの値か、どち...
...t[例][ruby]{
h = {:ab => "some" , :cd => "all"}
p h.shift #=> [:ab, "some"]
p h.shift #=> [:cd, "all"]
p h #=> {}
p h.shift #=> nil

h1 = Hash.new("default value")
p h1 #=> {}
p h1.shift #=> "default value...
..."

h2 = Hash.new {|*arg| arg}
p h2 #=> {}
p h2.shift #=> [{}, nil]
//}


@see Array#shift...
...します。

shift
は破壊的メソッドです。selfは要素を取り除かれた残りのハッシュに変更されます。


ハッシュが空の場合、デフォルト値に関わらず nil を返します。

//emlist[例][ruby]{
h = {:ab => "some" , :cd => "all"}
p h.shift...
...[:ab, "some"]
p h.shift #=> [:cd, "all"]
p h #=> {}
p h.shift #=> nil

h1 = Hash.new("default value")
p h1 #=> {}
p h1.shift #=> nil

h2 = Hash.new {|*arg| arg}
p h2 #=> {}
p h2.shift #=>...
...nil
//}


@see Array#shift...

Integer#chr -> String (25.0)

self を文字コードとして見た時に、引数で与えたエンコーディング encoding に対応する文字を返します。

...f を文字コードとして見た時に、引数で与えたエンコーディング encoding に対応する文字を返します。

//emlist[][ruby]{
p 65.chr
# => "A"
p 12354.chr
# => `chr': 12354 out of char range (RangeError)

p 12354.chr(Encoding::UTF_8)
# => "あ"
p 12354.chr(Encoding::EUC...
...順で優先的に解釈します。

//emlist[][ruby]{
p 0x79.chr.encoding # => #<Encoding:US_ASCII>
p 0x80.chr.encoding # => #<Encoding:ASCII_8BIT>
//}

@param encoding エンコーディングを表すオブジェクト。Encoding::UTF_8、'shift_jis' など。
@return 一文字からなる...
...文字列
@raise RangeError self を与えられたエンコーディングで正しく解釈できない場合に発生します。
@see String#ord Encoding.default_internal...

Integer#chr(encoding) -> String (25.0)

self を文字コードとして見た時に、引数で与えたエンコーディング encoding に対応する文字を返します。

...f を文字コードとして見た時に、引数で与えたエンコーディング encoding に対応する文字を返します。

//emlist[][ruby]{
p 65.chr
# => "A"
p 12354.chr
# => `chr': 12354 out of char range (RangeError)

p 12354.chr(Encoding::UTF_8)
# => "あ"
p 12354.chr(Encoding::EUC...
...順で優先的に解釈します。

//emlist[][ruby]{
p 0x79.chr.encoding # => #<Encoding:US_ASCII>
p 0x80.chr.encoding # => #<Encoding:ASCII_8BIT>
//}

@param encoding エンコーディングを表すオブジェクト。Encoding::UTF_8、'shift_jis' など。
@return 一文字からなる...
...文字列
@raise RangeError self を与えられたエンコーディングで正しく解釈できない場合に発生します。
@see String#ord Encoding.default_internal...