Skip to content

Old style Scala 2 If-else expression #2096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions _overviews/scala3-book/domain-modeling-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,7 @@ Here’s an example of a “string utilities” object that contains a set of me
object StringUtils:
def truncate(s: String, length: Int): String = s.take(length)
def containsWhitespace(s: String): Boolean = s.matches(".*\\s.*")
def isNullOrEmpty(s: String): Boolean =
if s == null || s.trim.equals("") then true else false
def isNullOrEmpty(s: String): Boolean = s == null || s.trim.isEmpty
```

We can use the object as follows:
Expand Down
4 changes: 1 addition & 3 deletions _overviews/scala3-book/taste-objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ For example, this `StringUtils` object contains a small collection of string-rel

```scala
object StringUtils:
def isNullOrEmpty(s: String): Boolean =
if (s==null || s.trim.equals("")) true else false
def isNullOrEmpty(s: String): Boolean = s == null || s.trim.isEmpty
def leftTrim(s: String): String = s.replaceAll("^\\s+", "")
def rightTrim(s: String): String = s.replaceAll("\\s+$", "")
```
Expand Down Expand Up @@ -93,4 +92,3 @@ NOTE: I don’t know if this is worth keeping, but I’m leaving it here as a co
{% endcomment %}