[問題] COUNT的有些用法看不太懂

作者: flyingIdea (飛翔的想法)   2013-12-17 15:24:17
http://ruby-doc.org/core-2.0.0/String.html
的count([other_str]+) → fixnum
這個章節
我看不太懂他\\的某些意思
1.
"hello^world".count "\\^aeiou" #=>4
應該是指 e*1 ^*1 o*2吧?
但是我改成
"hello^world".count "^aeiou" # => 8
為什麼會變成8@@?
2.
"hello world\\r\\n".count "X-\\w" #=> 3
這裡也看不太懂"X-\\w"是什麼意思
3.
"hello world".count "lo", "o" #=> 2
是因為hello world 所以是二次嗎?
感覺後面變二個參數後 就由字元比對變成字串比對了
是嗎?
4.
另外再外插一件和count無關的問題
books["Gravity's Rainbow"] = :splendid
這個是什麼意思?
請版上的各位先進幫我解答QQ~謝謝....

Links booklink

Contact Us: admin [ a t ] ucptt.com