2011-02-04 67 views
1

我发现了一个使用此函数的ruby加密库。Ruby 1.9.x未定义的方法^用于字符串

def process(text) 
    0.upto(text.length-1) {|i| text[i] = text[i]^round} 
    text 
end 
在红宝石1.9.x的

它抛出一个错误 - undefined method ^' for "\x1A":String__

有没有变通的方法在红宝石1.9.x的?

谷歌搜索后,我才知道“在Ruby 1.9中string [index]返回字符而不是字符的代码(就像它在1.8中)”(https://rails.lighthouseapp.com/projects/ 8994 /票/ 3144-未定义法换串ROR-234)

在此先感谢

+0

`text.each_byte.map {| b | (B ^圆).CHR} .join` – levinalex 2011-09-04 13:29:53

回答

相关问题