Hello:
1.9.3p194 :014 .blank?
= true
1.9.3p194 :015 [, ].blank?
= false
Proposal: the second line should also produce true.
Thoughts?
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Core group.
To view this discussion on the web visit
Michael,
That array isn't blank, empty strings aren't the same as nils. I think changing
that behavior would be confusing. If you don't want to count those elements,
it's probably best to filter the array for non-blank strings.
-Geoff
--
Geoff Harcourt
On Monday, July 9, 2012 at 10:15 AM,
On Jul 9, 2012, at 10:15 AM, Michael Boutros wrote:
Hello:
1.9.3p194 :014 .blank?
= true
1.9.3p194 :015 [, ].blank?
= false
Proposal: the second line should also produce true.
Thoughts?
If you really want to check for are all the values in this array blank, try:
Geoff,
But from the Rails documentation: An object is blank if it’s false, empty,
or a whitespace string. For example, “”, “ ”, nil, [], and {} are all
blank. That's why I think an array full of false, empty, or whitespace
strings should be empty.
- Michael
On Monday, July 9, 2012 10:18:04
On Mon, Jul 9, 2012 at 4:23 PM, Michael Boutros
michael.bout...@gmail.comwrote:
Geoff,
But from the Rails documentation: An object is blank if it’s false,
empty, or a whitespace string. For example, “”, “ ”, nil, [], and {} are
all blank. That's why I think an array full of false, empty, or
An object is blank if it’s false, empty, or a whitespace string. For
example, “”, “ ”, nil, [], and {} are all blank. That's why I think an
array full of false, empty, or whitespace strings should be empty.
But that's not mathematically accurate.
.size #= 0
[].size #= 1
[nil].size #= 1
An
Yes, we need #blank? to be extra expensive because beginners needn't
control what gets injected in their Arrays. Maybe `{ = }.blank?`
should be true, too?
Here you go:
class Array
def super_blank?
# Go!
end
end
Scott
On Mon, Jul 9, 2012 at 7:15 AM, Michael Boutros
The array has objects on it, so it isn't blank.
-
Maurício Linhares
http://techbot.me/ - http://twitter.com/#!/mauriciojr
On Monday, July 9, 2012 at 11:15 AM, Michael Boutros wrote:
Hello:
1.9.3p194 :014 .blank?
= true
1.9.3p194 :015 [, ].blank?
= false
Proposal: the
Empty means that it has no elements.
--
Oscar Del Ben
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)
On Monday, July 9, 2012 at 7:23 AM, Michael Boutros wrote:
Geoff,
But from the Rails documentation: An object is blank if it’s false, empty, or
a whitespace string. For