看板 Ruby 關於我們 聯絡資訊
※ 引述《ibad (ibad)》之銘言: : def letterM(getLetter) : alphaTB=Array.new() ^^^^^^^^^^^ : alphaTB = ('a'..'z').to_a 多餘的,因為你後面重新給值了, 結果你 new 出來的只會被 gc 掉 :o : 推 yzugsr:def ctoi(s) s[0]-96; end 12/21 11 這個做法雖然很常見,但在 ruby 1.9 已經行不通了, s[0] 會回傳 String, 而非 Fixnum (byte) 了。 要用 toki 的 unpack 或對 byte 操作(each_byte, bytes, etc.) -- In Lisp, you don't just write your program down toward the language, you also build the language up toward your program. 《Programming Bottom-Up》- Paul Graham 1993 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.135.28.18
yzugsr:QQ 12/21 11:59
ibad:感謝,大家都是好人,希望有机會再多上來問問題 :p 12/21 12:32