def prompt(msg,error) while(1) print msg + " " str = gets.chomp if yield str then return str else print error + "\n" end end end