るりまサーチ (Ruby 2.1.0)

最速Rubyリファレンスマニュアル検索!
3件ヒット [1-3件を表示] (0.052秒)
トップページ > バージョン:2.1.0[x] > クエリ:String[x] > クエリ:to[x] > クエリ:each_char[x] > ライブラリ:ビルトイン[x]

別のキーワード

  1. _builtin to_s
  2. openssl to_der
  3. openssl to_s
  4. _builtin to_a
  5. openssl to_pem

クラス

検索結果

String#each_char -> Enumerator (117649.0)

文字列の各文字に対して繰り返します。

文字列の各文字に対して繰り返します。

たとえば、
//emlist[][ruby]{
"hello世界".each_char {|c| print c, ' ' }
//}
は次のように出力されます。
h e l l o 世 界

@see String#chars

String#chars -> [String] (63478.0)

文字列の各文字を文字列の配列で返します。(self.each_char.to_a と同じです)

文字列の各文字を文字列の配列で返します。(self.each_char.to_a と同じです)

//emlist[例][ruby]{
"hello世界".chars # => ["h", "e", "l", "l", "o", "世", "界"]
//}

ブロックが指定された場合は String#each_char と同じように動作します。

Ruby 2.6 までは deprecated の警告が出ますが、Ruby 2.7 で警告は削除されました。

@see String#each_char

String#chars {|cstr| block } -> self (63178.0)

文字列の各文字を文字列の配列で返します。(self.each_char.to_a と同じです)

文字列の各文字を文字列の配列で返します。(self.each_char.to_a と同じです)

//emlist[例][ruby]{
"hello世界".chars # => ["h", "e", "l", "l", "o", "世", "界"]
//}

ブロックが指定された場合は String#each_char と同じように動作します。

Ruby 2.6 までは deprecated の警告が出ますが、Ruby 2.7 で警告は削除されました。

@see String#each_char