Im curious as to why we do not need to specify return "false" or "true" in this example?
Math is allowed, what you are getting is:
"Math::DomainError (Numerical argument is out of domain - "sqrt")"
you could use 'raise' to attend it or use logical expression to ensure the positive range of the number before use Math::sqrt
This comment is hidden because it contains spoiler information about the solution
Thanks for mentioning. I am new on this platform and didn't know the purpose of spoiler flag. Now I knnow. Thanks :)
Use spoiler flag, please.
You get this error when you pass a negative value to Math.sqrt. You can't pass negative to it.
i agree, for example 1e16+1 returns true when it shouldn't
@Wei-LiangChew I'm a little late but then the while loop will iterate over with n - 1 = 8 (and so on)
hmm.. i kept getting sqrt error. not sure why. thought Math.sqrt isn't supported here.
But what if the largest 5-digit number in digits doesn't start with 9?
This is better than using array.shift because it leaves array unaltered.
Or do variables duplicate when put as arguments anyway?
I'm going to say the same thing others have said...
I don't think it makes sense to disallow the use of alias_method if they aren't creating a unique method. This asks users to create an alias for a method while preventing them from using best practices. For newer programmers this could potentially teach them bad practices or confuse them on what the best practices are.
I recommend allowing the use of alias_method if the goal is to have users alias a method, or have them add a simple method like String#first or String#last to return the first or last character.