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

Comments

Projects
None yet
2 participants
@elfassy
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 in d463b24 Sep 2, 2015

@senny

This comment has been minimized.

Show comment
Hide comment
@senny

senny Sep 2, 2015

Member

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

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