Ruby/String/each

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск

Call each on a string with escape sequence

"foo\nbar".each { |x| puts x }
# foo
# bar



returning the length of each word

"In the early".split.each {
    |p| print p.length, " " 
}