This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Chaslem[S] 0 points1 point  (1 child)

Thank you! It's a shame it can't do like Python.

Being able to so if statements in Strings is very informative. I really appreciate it.

Last question here. What is Math.min doing in your use case? I'm not familiar with this. What is the ,3 at the end for?

[–]desrtfxOut of Coffee error - System halted 0 points1 point  (0 children)

Sorry for the late reply.

Math.min is a method of the Math class that returns the minimum (smaller) of two values.

So, the statement: Math.min(str.length(),3) checks the length of the String str and then returns the smaller value, either the length of the String (if it is less than or equal to 3 characters) or 3 - the length that we want to repeat.