るりまサーチ

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

別のキーワード

  1. _builtin each
  2. _builtin each_line
  3. prime each
  4. each
  5. tsort tsort_each

検索結果

ARGF.class#each_char -> Enumerator (18132.0)

レシーバに含まれる文字を一文字ずつブロックに渡して評価します。

...t2.txt
# $ ruby test.rb test1.txt test2.txt

# test.rb
ARGF.each_char # => #<Enumerator: ARGF:each_char>
ARGF.each_char{|e|p e}

# => "l"
# "i"
# "n"
# "e"
# "1"
# "\n"
# "l"
# "i"
# "n"
# "e"
# "2"
# "\n"

@see IO#each_char...

ARGF.class#each_char { |c| ... } -> self (18132.0)

レシーバに含まれる文字を一文字ずつブロックに渡して評価します。

...t2.txt
# $ ruby test.rb test1.txt test2.txt

# test.rb
ARGF.each_char # => #<Enumerator: ARGF:each_char>
ARGF.each_char{|e|p e}

# => "l"
# "i"
# "n"
# "e"
# "1"
# "\n"
# "l"
# "i"
# "n"
# "e"
# "2"
# "\n"

@see IO#each_char...

String#each_grapheme_cluster {|grapheme_cluster| block } -> self (6212.0)

文字列の書記素クラスタに対して繰り返します。

...ring#each_char と違って、
Unicode Standard Annex #29 (https://unicode.org/reports/tr29/)
で定義された書記素クラスタに対して繰り返します。

//emlist[例][ruby]{
"a\u0300".each_char.to_a.size # => 2
"a\u0300".each_grapheme_cluster.to_a.size # => 1
//}

@see String#grapheme...

String#each_grapheme_cluster -> Enumerator (6112.0)

文字列の書記素クラスタに対して繰り返します。

...ring#each_char と違って、
Unicode Standard Annex #29 (https://unicode.org/reports/tr29/)
で定義された書記素クラスタに対して繰り返します。

//emlist[例][ruby]{
"a\u0300".each_char.to_a.size # => 2
"a\u0300".each_grapheme_cluster.to_a.size # => 1
//}

@see String#grapheme...

Enumerator::Lazy#flat_map {|item| ... } -> Enumerator::Lazy (3106.0)

ブロックの実行結果をひとつに繋げたものに対してイテレートするような Enumerator::Lazy のインスタンスを返します。

...してイテレートするような
Enumerator::Lazy のインスタンスを返します。

//emlist[][ruby]{
["foo", "bar"].lazy.flat_map {|i| i.each_char.lazy}.force
#=> ["f", "o", "o", "b", "a", "r"]
//}

ブロックの返した値 x は、以下の場合にのみ分解され、連結され...
...それ以外のときは、x は分解されず、そのままの値として使われます。

//emlist[][ruby]{
[{a:1}, {b:2}].lazy.flat_map {|i| i}.force
#=> [{:a=>1}, {:b=>2}]
//}

@raise ArgumentError ブロックを指定しなかった場合に発生します。

@see Enumerable#flat_map...

絞り込み条件を変える

Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (132.0)

Rubyで使われる記号の意味(正規表現の複雑な記号は除く) ex q num per and or  plus minus ast slash hat sq  period comma langl rangl eq tilde  dollar at under lbrarbra  lbra2rbra2 lbra3rbra3 dq colon ac  backslash semicolon

...く)
ex q num per and or 
p
lus minus ast slash hat sq 
p
eriod comma langl rangl eq tilde 
dollar at under lbrarbra 
lbra2rbra2 lbra3rbra3 dq colon ac 
backslash semicolon

===[a:ex] !

: !true

not 演算子。d:spec/operator#notを参照...
...

: 3 != 5

「等しくない」比較演算子。d:spec/operator#notを参照。

: def xxx!

「!」はメソッド名の一部です。慣用的に、
同名の(! の無い)メソッドに比べてより破壊的な作用をもつメソッド(例: tr と tr!)で使われます。

: /xxx/...
...
全体で範囲式といいます。d:spec/operator#range。

: if /^begin/ .. /^end/ など 条件式 式 .. 式

条件式中の範囲式は特別にフリップフロップのように働きます。

//emlist{
'1234543212345'.each_char { |n| print( (n == ?2)..(n == ?4) ? n : '_' ) } #=...

NEWS for Ruby 3.0.0 (48.0)

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

...separated from positional arguments.
Code that resulted in deprecation warnings in Ruby 2.7 will now
result in ArgumentError or different behavior. 14183
* Procs accepting a single rest argument and keywords are no longer
subject to autosplatting. This now matches the behavior of Pro...
...cepting a single rest argument and no keywords.
16166

//emlist[][ruby]{
p
r = proc{|*a, **kw| [a, kw]}

p
r.call([1])
# 2.7 => [[1], {}]
# 3.0 => [[[1]], {}]

p
r.call([1, {a: 1}])
# 2.7 => [[1], {:a=>1}] # and deprecation warning
# 3.0 => a=>1}, {}]
//}

* Arguments forwarding (`...`) now suppo...
...* String#*
* String#capitalize
* String#center
* String#chomp
* String#chop
* String#delete
* String#delete_prefix
* String#delete_suffix
* String#downcase
* String#dump
* String#each_char
* String#each_grapheme_cluster
* String...