One minute
Multiple each_xxx method on string 🎉
Do you know there are multiple each_xxx methods available on String?
Code snippet 📌
"abc".each_char { |c| puts c }
# a
# b
# c
# => "abc"
"hello\nworld".each_line { |line| puts line }
# hello
# world
# => "hello\nworld"
"abc".each_byte { |b| puts b }
# 97
# 98
# 99
# => "abc"
"🙂🔥📣".each_codepoint { |c| puts c }
# 128578
# 128293
# 128227
# => "🙂🔥📣"
Read other posts
comments powered by Disqus