H
H
Hecntv2019-08-04 12:34:22
Ruby on Rails
Hecntv, 2019-08-04 12:34:22

How to hide the return data of the gets method in Ruby?

I can't find how to hide the return data from the gets method, here's an example:

puts "What are you name?"
a = gets.chomp
puts "My name " + a
=>What are you name?
=>User # как скрыть эти данные?
=>My name User

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
oh_shi, 2019-08-04
@Yelo

require 'io/console'
puts 'What is your name?'
name = STDIN.noecho(&:gets).chomp
puts "My name is #{name}."

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question