Skip to content
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

false.blank? => true #21468

Closed
elfassy opened this issue Sep 2, 2015 · 1 comment
Closed

false.blank? => true #21468

elfassy opened this issue Sep 2, 2015 · 1 comment

Comments

@elfassy
Copy link
Contributor

elfassy commented Sep 2, 2015

In the code currently we have

  # An object is blank if it's false, empty, or a whitespace string.
  # For example, '', '   ', +nil+, [], and {} are all blank.
  #
  # This simplifies
  #
  #   address.nil? || address.empty?
  #
  # to
  #
  #   address.blank?
  #
  # @return [true, false]
  def blank?
    respond_to?(:empty?) ? !!empty? : !self
  end

https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/object/blank.rb#L15

either the blank? function needs to change to

  def blank?
    respond_to?(:empty?) ? !!empty? : self.nil?
  end

or the description needs to be updated to

  # An object is blank if it's false, empty, or a whitespace string.
  # For example, false, '', '   ', +nil+, [], and {} are all blank.
  #
  # This simplifies
  #
  #   !address || address.empty?
  #
  # to
  #
  #   address.blank?
  #
  # @return [true, false]

thoughts?

@senny senny closed this as completed in d463b24 Sep 2, 2015
@senny
Copy link
Member

senny commented Sep 2, 2015

@elfassy good catch, I updated the docs accordingly. Thank you for reporting 💛

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants