Skip to content

Instantly share code, notes, and snippets.

@jonathanenlared
Last active August 29, 2015 14:16
Show Gist options
  • Save jonathanenlared/427665c24871746d580d to your computer and use it in GitHub Desktop.
Save jonathanenlared/427665c24871746d580d to your computer and use it in GitHub Desktop.
def ask_coord
valid = true
while valid
print "Introduzca la coordenada en formato fila,columna (ejemplo -> 1,4): "
coord = gets.chomp.split(',')
puts coord
for i in 0...2
coord[i] = coord[i].to_i
end
if coord.length != 2
puts "Coordenada invalida."
redo
elsif (coord[0] > 4 || coord[0] < 0) || (coord[1] > 4 || coord[1] < 0)
puts "Coordenada invalida."
redo
end
valid = false
return coord
end
end
def main
ask_coord
put ask_coord
end
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment