Mark T wrote:
All the best to all.
collection = [ nil, :this, nil, :that ]
collection.compact => [ :this, :that ]
T.
Mark T wrote:
All the best to all.
collection = [ nil, :this, nil, :that ]
collection.compact => [ :this, :that ]
T.
On 10/8/06, Marc H. [email protected] wrote:
to ask whether the spoon is full or empty, when there really is
no spoon.“Then by simple logic, the right solution will be to have it
return false”I dont think you can apply a lot of logic
on nil at all. Maybe not even a simple logic.
Hmm Tom and you have brought up the real question, who really is this
nil
buddy?
Modelling it correctly seems almost impossible, maybe you might want to
note
my “Void” proposals above ( I actually like that pun ;).
But I was quite convinced that from a less philosophical point of view,
defining NilClass#empty? should ring alarm bells in your head about the
design, which does not mean it is bad, you know once I calculated the
first
digit of Pi, still no one calculated the last, although I have asked
politely
and it turned out to be 2, so that was not a proof that my calculation
was
bad, but I checked them out nevertheless, and of course it was correct
anyway.
Hopefully that extreme example takes my point across, it would be most
interesting to have a look at the code where your NilClass#empty? was
necessary.
Cheers
Robert
–
Posted via http://www.ruby-forum.com/.
–
Deux choses sont infinies : l’univers et la bêtise humaine ; en ce qui
concerne l’univers, je n’en ai pas acquis la certitude absolue.
Is it possible for nothing to exist?
Logically not?
This must have been investigated many times before?
A vacum is not nothing.
Markt
Hal F. wrote:
I think/hope we all know that. The point is that there are times
when it feels natural to say: if x.empty?But circumstances force us to say: if x.nil? || x.empty?
or the equivalent.
Io has a neat idiom for things like this. Whereas a normal message pass
is:
size := list size
If you do:
size := list ?size
That’s equivalent to:
size := if(list, list size, nil) // that is, if/then/else
What’s nice is you can chain it:
size := animal ?limbs ?size
But in this situation, you could create a List isNotEmpty method and:
x ?isNotEmpty ifFalse(…)
Or something.
Devin
On 10/8/06, Robert D. [email protected] wrote:
On 10/8/06, Hal F. [email protected] wrote:
I do agree that making nil return true for #empty? is the
wrong solution.
Then by simple logic, the right solution will be to have it return false
No, that’s by simplistic logic. This is not a boolean situation; nil
is neither full nor empty. Is zero full or empty? Is a scrambled egg
full or empty?
Nil – and fixnums – belongs to an infinitely large class of things
which are not-containers. Since they aren’t containers, even asking
whether such things are empty is a nonsensical question.
-austin
On Sun, 8 Oct 2006, Robert D. wrote:
On 10/8/06, Hal F. [email protected] wrote:
I do agree that making nil return true for #empty? is the
wrong solution.Then by simple logic, the right solution will be to have it return false
na, read up on godel - every boolean language/situation also has a class
of
maybe/unknowable/paradox. this falls there.
-a
On 10/8/06, [email protected] [email protected] wrote:
Then by simple logic, the right solution will be to have it return false
2:0 for me
–
Deux choses sont infinies : l’univers et la bêtise humaine ; en ce qui
concerne l’univers, je n’en ai pas acquis la certitude absolue.
On 10/8/06, Robert D. [email protected] wrote:
On 10/8/06, [email protected] [email protected] wrote:
2:0 for me
Wait a minute, I just looked at my post, and I realize that I forgot
the
smiley…
so maybe I should not claim a score.
Robert
–
Deux choses sont infinies : l’univers et la bêtise humaine ; en ce qui
concerne l’univers, je n’en ai pas acquis la certitude absolue.
Austin Z. wrote:
No, that’s by simplistic logic. This is not a boolean situation; nil
is neither full nor empty. Is zero full or empty? Is a scrambled egg
full or empty?
Full… of yummy goodness!
Devin
The scrambled egg, that is… not the zero.
[email protected] wrote:
na, read up on godel - every boolean language/situation also has a class of
maybe/unknowable/paradox. this falls there.
Not so. A system has to reach a certain level of complexity for Gödel to
kick in. Arithmetic reaches that level. Boolean algebra does not.
Devin M. wrote:
Austin Z. wrote:
No, that’s by simplistic logic. This is not a boolean situation; nil
is neither full nor empty. Is zero full or empty? Is a scrambled egg
full or empty?
Full… of yummy goodness!Devin
The scrambled egg, that is… not the zero.
Stop him before he sings, “I Got Plenty O’ Nuthin’”
On 10/8/06, John W. Kennedy [email protected] wrote:
Then by simple logic, the right solution will be to have it return
falsena, read up on godel - every boolean language/situation also has a class
of
maybe/unknowable/paradox. this falls there.Not so. A system has to reach a certain level of complexity for Gödel to
kick in. Arithmetic reaches that level. Boolean algebra does not.
I only made a joke, apparently a very bad one :-(,
Ara however was not talking about Boolean Algreba but about
“Natural
Language talking about Boolean Algebra” and Gödel’s theorem does apply
of
course, as a matter of fact there are paradoxa well 20 times as old as
Gödel’s theorem talking about this.
E.g. the famous abou the Cretan saying that all Cretan lie all the time,
a
very nice analogy to Russel’s paradoxon of finite and infinite sets.
Well what a joke
Robert
–
John W. Kennedy
“The blind rulers of Logres
Nourished the land on a fallacy of rational virtue.”
– Charles Williams. “Taliessin through Logres: Prelude”
–
Deux choses sont infinies : l’univers et la bêtise humaine ; en ce qui
concerne l’univers, je n’en ai pas acquis la certitude absolue.
On Fri, 2006-10-06 at 03:21 +0900, Ohad L. wrote:
Show of hands - who thinks this is bad form?
class NilClass
def empty?; true; end
end
I missed this thread until now, so I’ll just raise my hand for the “Nil
is neither empty nor full, so it shouldn’t respond_to?(:empty?)” side of
the argument.
On Mon, 9 Oct 2006, John W. Kennedy wrote:
Then by simple logic, the right solution will be to have it return false
na, read up on godel - every boolean language/situation also has a class of
maybe/unknowable/paradox. this falls there.Not so. A system has to reach a certain level of complexity for Gödel to kick
in. Arithmetic reaches that level. Boolean algebra does not.
but we’re not talking about boolean logic? we’re talking about
‘statements’
made about the concept of nothing in the english language, specifically
nil.empty? # asserting must be either true or false in the thread
and i don’t think it’s the case that one can say that
((nil.empty? == true) -> false) -> true
in otherwords i don’t think it’s correct to say that, because “making
nil
return true for #empty? is the wrong solution” that making it return
false is
the right one - precisely because we’re not dealing with boolean logic
here.
at least, that’s my take on something entirely off-thread, but
interesting
nonetheless!
cheers.
-a
Just to throw a wrentch in the clockwork…what would an implementation
of the full? method look like?
Regards,
Jordan
MonkeeSage wrote:
Just to throw a wrentch in the clockwork…what would an implementation
of the full? method look like?
#full? isn’t the complement… it would be #non_empty? or the
equivalent.
Most containers in Ruby aren’t “full” unless memory is full.
Hal
On 10/8/06, [email protected] [email protected] wrote:
wrong solution.
kick
in. Arithmetic reaches that level. Boolean algebra does not.but we’re not talking about boolean logic? we’re talking about
‘statements’
made about the concept of nothing in the english language, specificallynil.empty? # asserting must be either true or false in the thread
nil.empty? => 42 e.g.
and i don’t think it’s the case that one can say that
((nil.empty? == true) → false) → true
in otherwords i don’t think it’s correct to say that, because “making nil
return true for #empty? is the wrong solution” that making it return false
is
the right one - precisely because we’re not dealing with boolean logic
here.
No of course not, my stupid? reply was not intended to be stupid though,
I
wanted to say, and strangely enough
I thaught that it was completely clear - I must have been kind of
[tw]ired
:
Hal said “nil.empty? => true === bad idea”
I thaught that he should have said “nil.respond_to? :empty? === bad
idea”
(regardeless of what I think about that matter).
at least, that’s my take on something entirely off-thread, but
interesting
nonetheless!
It is as a matter of fact and I really have to bite my tongue…
cheers.
-a
in order to be effective truth must penetrate like an arrow - and that is
likely to hurt. – wei wu weiRobert
–
Deux choses sont infinies : l’univers et la bêtise humaine ; en ce qui
concerne l’univers, je n’en ai pas acquis la certitude absolue.
On Oct 9, 2:36 am, Hal F. [email protected] wrote:
Most containers in Ruby aren’t “full” unless memory is full.
Semantics, schemantics…what I’m wondering is what the “full?” (or if
you prefer “non_empty?”) method would look like. I have a feeling that
it would make a distinction between the value of the variable and the
value of the object, depending on the context. And if that’s true,
then in some context, nil.empty? == true is correct. But I’ve been
known to be silly before, so mabye this is just another instance of
that pattern.
Regards,
Jordan
Robert D. wrote:
Hal said “nil.empty? => true === bad idea”
I thaught that he should have said “nil.respond_to? :empty? === bad idea”
(regardeless of what I think about that matter).
Yes, that is what I meant and should have said.
Of course, even then nil.empty? doesn’t return true… or false…
it raises an exception.
So it’s still true to say that it doesn’t return true.
This is like the Zen master asking the novice when the fire went out,
did it go to the east, west, north, or south?
Hal
On 10/10/06, Hal F. [email protected] wrote:
Robert D. wrote:
Hal said “nil.empty? => true === bad idea”
I thaught that he should have said “nil.respond_to? :empty? === bad
idea”
(regardeless of what I think about that matter).Yes, that is what I meant and should have said.
Yeah but it was completely clear, save for nubies but it was not a nuby
thread, yet I had to make a stupid remark, and lots of noise
Of course, even then nil.empty? doesn’t return true… or false…
it raises an exception.
So it’s still true to say that it doesn’t return true.
This is like the Zen master asking the novice when the fire went out,
did it go to the east, west, north, or south?
Good one, I gotta translate that one, that is quite a challenge
Hal
Deux choses sont infinies : l’univers et la bêtise humaine ; en ce qui
concerne l’univers, je n’en ai pas acquis la certitude absolue.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs