Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created January 22, 2019 00:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/15bfa4a80a226365e72ac96785d787c3 to your computer and use it in GitHub Desktop.
Save parzibyte/15bfa4a80a226365e72ac96785d787c3 to your computer and use it in GitHub Desktop.
arreglo = ["Ruby", "Perl", "C", "Go", "Rust"]
# index devuelve el índice (desde 0) o nil si no existe
busqueda = "Perl"
indice = arreglo.index(busqueda)
if indice
puts "El elemento #{busqueda} está en el índice #{indice}"
else
puts "No existe el elemento #{busqueda}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment