This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Question Asker | |
| def ask question | |
| puts question | |
| answer = gets.chomp | |
| answer | |
| end | |
| # Yes/No Question Asker | |
| def ask_yn question | |
| puts question |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Asks yes/no questions; validates the answer | |
| def ask_yn question | |
| puts question | |
| answer = gets.chomp.downcase | |
| while answer != ('yes' || 'no') | |
| puts 'Please answer \'yes\' or \'no\'.' | |
| answer = gets.chomp.downcase | |
| end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def ask question | |
| puts question | |
| answer = gets.chomp | |
| answer | |
| end | |
| answer_1 = ask question_1 |
NewerOlder