Logo

Programming-Idioms

History of Idiom 110 > diff from v23 to v24

Edit summary for version 24 by Okx:
New Elixir implementation by user [Okx]

Version 23

2016-08-11, 20:12:18

Version 24

2018-03-21, 21:21:01

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
blank = s == nil || String.length(String.trim s) == 0
Doc URL
https://hexdocs.pm/elixir/String.html
Demo URL
https://tio.run/##LYwxDsIwFEN3TmFlaqVQdUbkAEwMjA1CLf20EZ8flGRg6N3TtGKwJVvPJnY/F/LLB0Scj@iU0hDHGsoKUGQTSqWAmZi9FXXH6PPAvbxhysiYjcey4JaCk6lhkinN1T8V/yDWG9bmy7VxEr/0TIga3A/EJyT/iDtb7af1gWTMKw