我有一个这样的数组
array = ["a", nil, "b"]
当我join
像这样运行它时
result = array.join
并且puts
,result
我得到“ab”,而不是“ab”。
帮助!
编辑请在我的实际代码的上下文中理解这一点:
def caesar_cipher(initial_string, shift_number)
letter_list = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
modified_initial_string = initial_string.split("")
modified_initial_string.map! { |letter|
letter.downcase!
if letter_list.include?(letter)
letter = letter_list[letter_list.index(letter) - shift_number]
end
}
result = modified_initial_string.join
puts modified_initial_string
puts result
end
caesar_cipher("Hello this", 1)
我在终端的结果是:
g
d
k
k
n
s
g
h
r
gdkknsghr