fork download
  1. def includes(array, valor)
  2. for item in array
  3. if item == valor
  4. return true
  5. end
  6. end
  7. return false
  8. end
  9.  
  10. chutes_ate_agora = ["a","b","c","d"]
  11. novo_chute = gets.strip
  12. teste = includes(chutes_ate_agora, novo_chute)
  13. if teste then
  14. puts "já chutou letra #{novo_chute}"
  15. else
  16. chutes_ate_agora << novo_chute
  17. end
  18. print chutes_ate_agora
  19.  
  20. #https://pt.stackoverflow.com/q/257960/101
Success #stdin #stdout 0.01s 5884KB
stdin
c
stdout
já chutou letra c
["a", "b", "c", "d"]