nus-cs2113-AY2021S2 / forum

5 stars 0 forks source link

Usage of strip() vs trim() #17

Open blank-bank opened 3 years ago

blank-bank commented 3 years ago

Hi Prof, can i check if there are any preferences between the usage of strip() and trim() function? Ex 7 does not permit the usage of strip() from the result of my submissions.

Ive read

https://www.journaldev.com/33291/java-string-trim-method-examples#:~:text=This%20method%20uses%20Unicode%20code,it%20uses%20the%20Unicode%20standard.

and it suggests to use strip() instead of trim(). Would like to ask for any guidance on this issue. Thank you!

okkhoy commented 3 years ago

Errr.. this is embarrassing. The default version of Java used by classroom auto-grader is Java 1.8, which doesn't recognize strip(). It is embarrassing because of 2 reasons:

  1. we just followed the sample setup for Java auto-grader and did not update the build.gradle file to use Java 11.
  2. we were used to using trim() from previous iterations and never checked for strip() which would have caught the issue.

Since this assignment is already published, please use trim() to keep the auto-grader happy.

In fact, the hint in the module website also suggests trim() image

Playing coverup: trim is not deprecated, so we are not completely wrong 😜 On a serious note: we will work to ensure both trim/strip are accepted in the future; thanks for highlighting.

blank-bank commented 3 years ago

Thanks Prof! Appreciate the honesty :)