2012-02-17 12 views
5
print "Enter your password: " 
pass = STDIN.noecho(&:gets) 
puts "Your password is #{pass}!" 

USCITA:Perché non è possibile utilizzare il metodo di istanza noecho della classe IO?

Enter your password: input.rb:2:in `<main>': undefined method `noecho' for #<IO:<STDIN>> (NoMethodError) 
+0

Non esiste metodo per STDIN, un'occhiata a [questo post] (http: //stackoverflow.com/questions/3699134/ruby-stdin-gets-without-show-chars-on-screen) per vedere come accettare la password –

+0

Possibile duplicato di http://stackoverflow.com/questions/133719/how- posso-i-read-a-passwo rd – nkm

+0

Grazie mille, con highline è okey! – user1215688

risposta

10

All'inizio

require 'io/console' 

tardi Rubino 1.9.3

Problemi correlati