Logo

Programming-Idioms

History of Idiom 110 > diff from v25 to v26

Edit summary for version 26 by Debaran:
New Scala implementation by user [Debaran]

Version 25

2019-01-23, 19:07:36

Version 26

2019-02-02, 02:21:11

Idiom #110 Check if string is blank

Set boolean blank to true if string s is empty, or null, or contains only whitespace ; false otherwise.

Idiom #110 Check if string is blank

Set boolean blank to true if string s is empty, or null, or contains only whitespace ; false otherwise.

Code
val blank = s.trim().isEmpty()
Comments bubble
Use strip (Java 11) instead of trim for Unicode-awareness, or more simply use isBlank (Java 11)