Skip to content

Commit 430b74d

Browse files
committed
Default answer defaults to nil.
As @trans pointed out: not not all questions are necessarily "Yn". And if default answer is nil, one can do ```ruby if answer = ask("Some question?") # do something with answer else # no answer end ```
1 parent f696f0b commit 430b74d

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

lib/clik/ask.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module Kernel
66
# via the console. A prompt will be sent to $stdout,
77
# if given, and the input taken from $stdin...
88
#
9-
# ask "Are you happy? [Yn]" "Y"
9+
# ask "Are you happy? [Yn]", "Y"
1010
#
1111
# On the command line one would see...
1212
#
@@ -19,7 +19,7 @@ module Kernel
1919
# The ask method would return "Y".
2020
#
2121
# Returns [String]
22-
def ask(prompt=nil, default_answer=Y)
22+
def ask(prompt=nil, default_answer=nil)
2323
$stdout << "#{prompt}"
2424
$stdout.flush
2525
ans = $stdin.gets.chomp!
@@ -29,6 +29,5 @@ def ask(prompt=nil, default_answer=Y)
2929
ans
3030
end
3131
end
32-
3332
end
3433

0 commit comments

Comments
 (0)