【发布时间】:2021-05-05 07:28:39
【问题描述】:
为什么从我的数组中打印超过 2 个值时,我的代码会返回 ArgumentError?
代码:
gamestate = Array['1','2','3','4','5','6','7','8','9']
player = 'X' #x is the first player#
turns = 0 # number of turns that have passed
puts "TICTACTOE"#prints initial screen{#
puts gamestate[0,1,2]
puts gamestate[3,4,5]
puts gamestate[6,7,8]
错误:
Traceback (most recent call last):
1: from C:/Users/Hunter/Desktop/programming/rubyprograms/Basics/tictactoe.rb:5:in `<main>'
C:/Users/Hunter/Desktop/programming/rubyprograms/Basics/tictactoe.rb:5:in `[]': wrong number of arguments (given 3, expected 1..2) (ArgumentError)
<hr>
【问题讨论】: