Open
Conversation
Collaborator
CalculatorWhat We're Looking For
Great work overall! |
| @@ -0,0 +1,59 @@ | |||
| def r_or_z(n) | |||
| if n.include?(".") | |||
| return n.to_f | |||
Collaborator
There was a problem hiding this comment.
This is a clever way to figure out what's needed here.
|
|
||
| symbol="unvalid" | ||
|
|
||
| while symbol !="valid" do |
Collaborator
There was a problem hiding this comment.
I like the idea of using a variable to track whether the loop has to restart. As long as there's only two possibilities (valid and invalid), it's common to use a boolean in this role, something like:
valid_symbol = false
while !valid_symbol do
# ...| while n2==0 do | ||
| puts "It is no possible to divide by 0. Please enter a valid number" | ||
| n2=gets.chomp | ||
| n2=r_or_z(n2) |
Collaborator
There was a problem hiding this comment.
Watch your spacing here. Good style is usually to put a space on either side of an equals sign or operator, like n2 = gets.chomp
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Calculator
Congratulations! You're submitting your assignment.
Comprehension Questions