Skip to content

Commit c3a58d3

Browse files
authored
Using Scala 2 If-else expression instead
if (<condition>) <doThis> else <doThat> syntax is from Scala 2. Use if <condition> then <doThis> else <doThat> instead or simplify it by removing the if-else expression. If-else is unnecessary
1 parent 69520e5 commit c3a58d3

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

_overviews/scala3-book/taste-objects.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ For example, this `StringUtils` object contains a small collection of string-rel
2727

2828
```scala
2929
object StringUtils:
30-
def isNullOrEmpty(s: String): Boolean =
31-
if (s==null || s.trim.equals("")) true else false
30+
def isNullOrEmpty(s: String): Boolean = s==null || s.trim.equals("")
3231
def leftTrim(s: String): String = s.replaceAll("^\\s+", "")
3332
def rightTrim(s: String): String = s.replaceAll("\\s+$", "")
3433
```

0 commit comments

Comments
 (0)