为什么这个字符串值是一个数字?
问题描述:
在Ruby Koans中,您必须填写下面代表string[1]
的空白。为什么答案是97?为什么这个字符串值是一个数字?
def test_you_can_get_a_single_character_from_a_string
string = "Bacon, lettuce and tomato"
assert_equal ___ , string[1]
end
答
97是小写字母a的ASCII值(十进制)。
你从哪里得到koan?该公司在[三月]发生了变化(https://github.com/edgecase/ruby_koans/commit/a46642e192844a312c344d43147a81ecf43f438b)。 –
你期待着答案是什么? –
安德鲁,http://koans.heroku.com – Simpleton