Skip to content
Open
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
14 changes: 14 additions & 0 deletions src/string.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3028,6 +3028,20 @@ class String
true
end

# Returns `true` if `self` is not `#blank?`.
#
# ```
# "a".present? # => true
# "".present? # => false
# " ".present? # => false
# " a ".present? # => true
# ```
#
# See also: `Object#blank?`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method doesn't exist...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# See also: `Object#blank?`.
# See also: `String#blank?`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def present? : Bool
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should add test coverage on this as well.

!blank?
end

# Returns `self` unless `#blank?` is `true` in which case it returns `nil`.
#
# ```
Expand Down