Proposal: let kind_of take more arguments


(Simon Strandgaard) #1

It just hit me… why not let kind_of? take more arguments?

irb(main):001:0> x = 3
=> 3
irb(main):002:0> x.kind_of?(String)
=> false
irb(main):003:0> x.kind_of?(String, Fixnum)
ArgumentError: wrong number of arguments(2 for 1)
from (irb):3:in `kind_of?'
from (irb):3
irb(main):004:0>

For instance I have

def push(choice)
if choice.kind_of?(Zero) == false and choice.kind_of?(One) == false
raise "got #{choice.class}"
end
@choices << choice
end

It could turn into

def push(choice)
unless choice.kind_of?(Zero, One)
raise "got #{choice.class}"
end
@choices << choice
end

···


Simon Strandgaard


(Robert) #2

“Simon Strandgaard” neoneye@adslhome.dk schrieb im Newsbeitrag
news:pan.2004.02.19.14.25.27.611885@adslhome.dk

It just hit me… why not let kind_of? take more arguments?

irb(main):001:0> x = 3
=> 3
irb(main):002:0> x.kind_of?(String)
=> false
irb(main):003:0> x.kind_of?(String, Fixnum)
ArgumentError: wrong number of arguments(2 for 1)
from (irb):3:in `kind_of?'
from (irb):3
irb(main):004:0>

For instance I have

def push(choice)
if choice.kind_of?(Zero) == false and choice.kind_of?(One) == false

Never compare boolean values to get boolean values. This can lead to
hideous bugs if the method at hand does not return “true” or “false” -
especially with languages that have more than one value for either.

raise "got #{choice.class}"

end
@choices << choice
end

It could turn into

def push(choice)
unless choice.kind_of?(Zero, One)
raise “got #{choice.class}”

ArgumentError is a good choice here. :slight_smile:

end
@choices << choice
end

Why don’t you just do

def push(choice)
case choice
when Zero, One
@choices << choice
else
raise ArgumentError, "got #{choice.class}"
end
end

or

def push(choice)
raise ArgumentError, “got #{choice.class}” unless [Zero,
One].map{|cl|choice.kind_of? cl}.any?
@choices << choice
end

or

class Object
def kind_of_any?( *classes )
classes.each{|cl| return true if kind_of? cl}
false
end
end

Then:

def push(choice)
raise ArgumentError, “got #{choice.class}” unless
choice.kind_of_any?(Zero, One)
@choices << choice
end

Regards

robert

(Ara.T.Howard) #3

Date: Thu, 19 Feb 2004 15:25:27 +0100
From: Simon Strandgaard neoneye@adslhome.dk
Newsgroups: comp.lang.ruby
Subject: proposal: let kind_of take more arguments

It just hit me… why not let kind_of? take more arguments?

this is a good idea regardless of your exact situation - it reads nicer than a
case, which i generally use for this

-a

···

On Thu, 19 Feb 2004, Simon Strandgaard wrote:

irb(main):001:0> x = 3
=> 3
irb(main):002:0> x.kind_of?(String)
=> false
irb(main):003:0> x.kind_of?(String, Fixnum)
ArgumentError: wrong number of arguments(2 for 1)
from (irb):3:in `kind_of?'
from (irb):3
irb(main):004:0>

For instance I have

def push(choice)
if choice.kind_of?(Zero) == false and choice.kind_of?(One) == false
raise "got #{choice.class}"
end
@choices << choice
end

It could turn into

def push(choice)
unless choice.kind_of?(Zero, One)
raise "got #{choice.class}"
end
@choices << choice
end


Simon Strandgaard

EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
URL :: http://www.ngdc.noaa.gov/stp/
TRY :: for l in ruby perl;do $l -e “print “\x3a\x2d\x29\x0a””;done
===============================================================================


(Nobuyoshi Nakada) #4

Hi,

At Fri, 20 Feb 2004 20:20:09 +0900,
Simon Strandgaard wrote in [ruby-talk:93193]:

It could turn into

def push(choice)
unless choice.kind_of?(Zero, One)
raise "got #{choice.class}"
end
@choices << choice
end

unless [Zero, One].any? {|klass| choice.kind_of?(klass)}

Or shorter

unless [Zero, One].any?(&choice.method(:kind_of?)
···


Nobu Nakada


(Yukihiro Matsumoto) #5

Hi,

···

In message “proposal: let kind_of take more arguments” on 04/02/20, Simon Strandgaard neoneye@adslhome.dk writes:

It just hit me… why not let kind_of? take more arguments?

kinf_of? method easily hinders “duck typing”, so that I don’t feel
good to make it easier to use.

						matz.

(Simon Strandgaard) #6

“Simon Strandgaard” neoneye@adslhome.dk schrieb im Newsbeitrag

def push(choice)
if choice.kind_of?(Zero) == false and choice.kind_of?(One) == false

Never compare boolean values to get boolean values. This can lead to
hideous bugs if the method at hand does not return “true” or “false” -
especially with languages that have more than one value for either.

Thanks for the warning. I have actually had a few problems with it
earlier, without realizing this.

def push(choice)
unless choice.kind_of?(Zero, One)
raise “got #{choice.class}”

ArgumentError is a good choice here. :slight_smile:

I don’t have full overview over Ruby’s exception hierarchy, but yes
I should use this one here (which I do now). :wink:

end
@choices << choice
end

Why don’t you just do

def push(choice)
case choice
when Zero, One
@choices << choice
else
raise ArgumentError, "got #{choice.class}"
end
end

a switch statement… easier to read.
However I like to do bailout as soon as possible,
raising ArgumentError this late may make confusion.

or

def push(choice)
raise ArgumentError, “got #{choice.class}” unless [Zero,
One].map{|cl|choice.kind_of? cl}.any?
@choices << choice
end

Confusion :slight_smile:

def Object#kind_of_any?( *classes )

Yes thought of this… which maked me propose this idea.

···

On Thu, 19 Feb 2004 15:43:05 +0100, Robert Klemme wrote:


Simon Strandgaard


(Ara.T.Howard) #7

what do you reccomend (when a case won’t do) ?


unless choice.kind_of?(Zero) or choice.kind_of?(One)

-a

···

On Thu, 19 Feb 2004, Robert Klemme wrote:

Date: Thu, 19 Feb 2004 15:43:05 +0100
From: Robert Klemme bob.news@gmx.net
Newsgroups: comp.lang.ruby
Subject: Re: proposal: let kind_of take more arguments

“Simon Strandgaard” neoneye@adslhome.dk schrieb im Newsbeitrag
news:pan.2004.02.19.14.25.27.611885@adslhome.dk

It just hit me… why not let kind_of? take more arguments?

irb(main):001:0> x = 3
=> 3
irb(main):002:0> x.kind_of?(String)
=> false
irb(main):003:0> x.kind_of?(String, Fixnum)
ArgumentError: wrong number of arguments(2 for 1)
from (irb):3:in `kind_of?'
from (irb):3
irb(main):004:0>

For instance I have

def push(choice)
if choice.kind_of?(Zero) == false and choice.kind_of?(One) == false

Never compare boolean values to get boolean values. This can lead to
hideous bugs if the method at hand does not return “true” or “false” -
especially with languages that have more than one value for either.

EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
URL :: http://www.ngdc.noaa.gov/stp/
TRY :: for l in ruby perl;do $l -e “print “\x3a\x2d\x29\x0a””;done
===============================================================================


(Simon Strandgaard) #8

Ok, glad you like it. I have submitted an RCR of it,
please vote on it.

http://rcrchive.net/rcr/RCR/RCR218

···

On Thu, 19 Feb 2004 08:21:23 -0700, Ara.T.Howard wrote:

On Thu, 19 Feb 2004, Simon Strandgaard wrote:

It just hit me… why not let kind_of? take more arguments?

this is a good idea regardless of your exact situation - it reads nicer than a
case, which i generally use for this


Simon Strandgaard


(Gavin Kistner) #9

Or, as I noted on the RCR:

   unless ([Zero,One] & choice.class.ancestors).length>0
···

nobu.nokada@softhome.net wrote:

unless [Zero, One].any? {|klass| choice.kind_of?(klass)}

Or shorter

unless [Zero, One].any?(&choice.method(:kind_of?)


(-, /\ / / //


(Robert) #10

“Simon Strandgaard” neoneye@adslhome.dk schrieb im Newsbeitrag
news:pan.2004.02.19.14.51.57.777201@adslhome.dk

“Simon Strandgaard” neoneye@adslhome.dk schrieb im Newsbeitrag

def push(choice)
if choice.kind_of?(Zero) == false and choice.kind_of?(One) == false

Never compare boolean values to get boolean values. This can lead to
hideous bugs if the method at hand does not return “true” or “false” -
especially with languages that have more than one value for either.

Thanks for the warning. I have actually had a few problems with it
earlier, without realizing this.

:-))

I forgot to mention, that it’s totally superfluous, too, and thus may cost
you some machine cycles… :-))

def push(choice)
unless choice.kind_of?(Zero, One)
raise “got #{choice.class}”

ArgumentError is a good choice here. :slight_smile:

I don’t have full overview over Ruby’s exception hierarchy, but yes
I should use this one here (which I do now). :wink:

:-))

end
@choices << choice
end

Why don’t you just do

def push(choice)
case choice
when Zero, One
@choices << choice
else
raise ArgumentError, "got #{choice.class}"
end
end

a switch statement… easier to read.
However I like to do bailout as soon as possible,
raising ArgumentError this late may make confusion.

What do you mean by “late”? Do you mean that the line with “raise” stands
below the actual operation. Didn’t think of that, but yes, it might be
confusing. OTOH, if you can read “case” then it’s not so difficult, is
it?

or

def push(choice)
raise ArgumentError, “got #{choice.class}” unless [Zero,
One].map{|cl|choice.kind_of? cl}.any?
@choices << choice
end

Confusion :slight_smile:

http://lyricsheaven.topcities.com/survey_d_k_bestanden/ELO.htm#confusion

def Object#kind_of_any?( *classes )

Yes thought of this… which maked me propose this idea.

I’m wondering though whether it’s worth the effort. When using duck
typing, you don’t need kind_of? anyway.

Btw, I had another idea:

PUSH_ALLOWED = {Zero, One}

def push(choice)
raise ArgumentError, “got #{choice.class}” unless
PUSH_ALLOWED[choice.class]
@choices << choice
end

Of course there is a subtle difference since this does not take sub
classes into consideration. But other than that, it should be faster -
especially if you have more classes that shoule be checked.

:slight_smile:

Kind regards

robert
···

On Thu, 19 Feb 2004 15:43:05 +0100, Robert Klemme wrote:


(Simon Strandgaard) #11

My brain is terrible at dealing with ‘unless’.
If its just “unless something” then its ok.
But when its “unless a or b and c” then it chokes.

Am I the only one feeling like this?

Where can I seek help ? :wink:

···

On Thu, 19 Feb 2004 08:19:33 -0700, Ara.T.Howard wrote:

what do you reccomend (when a case won’t do) ?


unless choice.kind_of?(Zero) or choice.kind_of?(One)


Simon Strandgaard


(Robert) #12

“Ara.T.Howard” ahoward@fattire.ngdc.noaa.gov schrieb im Newsbeitrag
news:Pine.LNX.4.44.0402190818210.8086-100000@fattire.ngdc.noaa.gov

Date: Thu, 19 Feb 2004 15:43:05 +0100
From: Robert Klemme bob.news@gmx.net
Newsgroups: comp.lang.ruby
Subject: Re: proposal: let kind_of take more arguments

“Simon Strandgaard” neoneye@adslhome.dk schrieb im Newsbeitrag
news:pan.2004.02.19.14.25.27.611885@adslhome.dk

It just hit me… why not let kind_of? take more arguments?

irb(main):001:0> x = 3
=> 3
irb(main):002:0> x.kind_of?(String)
=> false
irb(main):003:0> x.kind_of?(String, Fixnum)
ArgumentError: wrong number of arguments(2 for 1)
from (irb):3:in `kind_of?'
from (irb):3
irb(main):004:0>

For instance I have

def push(choice)
if choice.kind_of?(Zero) == false and choice.kind_of?(One) ==
false

Never compare boolean values to get boolean values. This can lead to
hideous bugs if the method at hand does not return “true” or “false” -
especially with languages that have more than one value for either.

what do you reccomend (when a case won’t do) ?


unless choice.kind_of?(Zero) or choice.kind_of?(One)

Exactly. Boolean operators are for transformation of boolean values.
Comparison with ‘true’, ‘false’, ‘nil’ or whatever is not appropriate for
the stated reasons.

:slight_smile:

robert
···

On Thu, 19 Feb 2004, Robert Klemme wrote:


(Robert) #13

“Gavin Kistner” gavin@refinery.com schrieb im Newsbeitrag
news:3boZb.87208$uV3.550379@attbi_s51…

unless [Zero, One].any? {|klass| choice.kind_of?(klass)}

Or shorter

unless [Zero, One].any?(&choice.method(:kind_of?)

Or, as I noted on the RCR:

   unless ([Zero,One] & choice.class.ancestors).length>0

if ([Zero,One] & choice.class.ancestors).empty?

:-))

···

nobu.nokada@softhome.net wrote:


(-, /\ / / //


(Gavin Kistner) #14

Gavin Kistner wrote:

···

nobu.nokada@softhome.net wrote:

unless [Zero, One].any? {|klass| choice.kind_of?(klass)}

Or shorter

unless [Zero, One].any?(&choice.method(:kind_of?)

Or, as I noted on the RCR:

  unless ([Zero,One] & choice.class.ancestors).length>0

For the curious, here’s how the three methods above stack up in terms of
performance (see below stupid test code that should probably be using
Ruby’s built-in profiling for the results). The summary is: The third
method above is generally faster, unless there’s a high probability that
a match will be found early on in your test list, in which case the
first example above is fastest.

------------------------------------

instance = ValidForm::Text.new(‘userName’);
testList = [
{:classes =>
[Array,ValidForm::OptionSet,Module,Method,Fixnum],
:name=>‘No match is found:’},
{:classes =>
[Array,ValidForm::OptionSet,Module,Method,Object],
:name=>‘Match at end of list:’},
{:classes =>
[Object,Array,ValidForm::OptionSet,Module,Method],
:name=>‘Match at start of list:’}
]

n=50000

puts instance.class.ancestors.join(’,’)

testList.each{ |test|
classes=test[:classes]
puts test[:name]
s1 = Time.now
n.times{
(classes & instance.class.ancestors).length>0
}
s2 = Time.now
printf “Using set intersection: %.2f\n”,(s2-s1)

s1 = Time.now
n.times{
	classes.any?{ |k| instance.kind_of?(k) }
}
s2 = Time.now
printf "  Using explicit block: %.2f\n",(s2-s1)

s1 = Time.now
n.times{
	classes.any?(&instance.method(:kind_of?))
}
s2 = Time.now
printf "Passing kind_of? block: %.2f\n",(s2-s1)
puts

}

OUTPUTS

ValidForm::Text,ValidForm::Field,Object,Kernel

No match is found:
Using set intersection: 1.17
Using explicit block: 1.38
Passing kind_of? block: 2.24

Match at end of list:
Using set intersection: 1.18
Using explicit block: 1.21
Passing kind_of? block: 2.27

Match at start of list:
Using set intersection: 1.19
Using explicit block: 0.46
Passing kind_of? block: 1.26


(-, /\ / / //


(Simon Strandgaard) #15

“Simon Strandgaard” neoneye@adslhome.dk schrieb im Newsbeitrag

Why don’t you just do

def push(choice)
case choice
when Zero, One
@choices << choice
else
raise ArgumentError, "got #{choice.class}"
end
end

a switch statement… easier to read.
However I like to do bailout as soon as possible,
raising ArgumentError this late may make confusion.

What do you mean by “late”? Do you mean that the line with “raise” stands
below the actual operation. Didn’t think of that, but yes, it might be
confusing. OTOH, if you can read “case” then it’s not so difficult, is
it?

It isn’t clear at first sight when the method bailouts, and if
the switch statement spans over many lines, then its not visible at all
that its capable of raising exceptions.

Kind_of? similar to bouncer pattern, see
http://www.rubygarden.org/ruby?BouncerPattern

Confusion :slight_smile:

http://lyricsheaven.topcities.com/survey_d_k_bestanden/ELO.htm#confusion

:slight_smile:

def Object#kind_of_any?( *classes )

Yes thought of this… which maked me propose this idea.

I’m wondering though whether it’s worth the effort. When using duck
typing, you don’t need kind_of? anyway.

Btw, I had another idea:

PUSH_ALLOWED = {Zero, One}

def push(choice)
raise ArgumentError, “got #{choice.class}” unless
PUSH_ALLOWED[choice.class]
@choices << choice
end

Good idea, but gives a complex impression at first sight.

Of course there is a subtle difference since this does not take sub
classes into consideration. But other than that, it should be faster -
especially if you have more classes that shoule be checked.

Im in the make it work phase.

There is 3 phases:

  1. make it work
  2. make it right
  3. make it fast :wink:
···

On Thu, 19 Feb 2004 16:14:13 +0100, Robert Klemme wrote:

On Thu, 19 Feb 2004 15:43:05 +0100, Robert Klemme wrote:


Simon Strandgaard


(Ara.T.Howard) #16

a digital logic book, the simplest, will help. de morgan’s laws…, eg.

noting that ‘unless’ is the negation of ‘if’, in otherwords ‘unless’ => ‘if
not’

let

^ => and

v => or

~ => negation 

Z => kind_of? Zero

O => kind_of? One 

then we can say your original statement

choice.kind_of?(Zero) == false and choice.kind_of?(One) == false

as simply

~Z ^ ~O

if we want use this conjunction in the negative sense (convert to ‘unless’)
we can convert using the following heuristic ‘negate each clause and flip
the operation’

so

~(~Z ^ ~O) => Z v 0

or

choice.kind_of?(Zero) or choice.kind_of?(One)

now we have the negation of the conjuction. this is want we want though
since were are trying to use it in the negative sense (unless). eg. we’re
done:

unless choice.kind_of?(Zero) or choice.kind_of?(One)
  ...
end

if you express in simple terms it’s pretty easy. eg.

HTH.

-a

···

On Thu, 19 Feb 2004, Simon Strandgaard wrote:

Date: Thu, 19 Feb 2004 16:29:42 +0100
From: Simon Strandgaard neoneye@adslhome.dk
Newsgroups: comp.lang.ruby
Subject: Re: proposal: let kind_of take more arguments

On Thu, 19 Feb 2004 08:19:33 -0700, Ara.T.Howard wrote:

what do you reccomend (when a case won’t do) ?


unless choice.kind_of?(Zero) or choice.kind_of?(One)

My brain is terrible at dealing with ‘unless’.
If its just “unless something” then its ok.
But when its “unless a or b and c” then it chokes.

Am I the only one feeling like this?

Where can I seek help ? :wink:

EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
URL :: http://www.ngdc.noaa.gov/stp/
TRY :: for l in ruby perl;do $l -e “print “\x3a\x2d\x29\x0a””;done
===============================================================================


(Robert) #17

“Simon Strandgaard” neoneye@adslhome.dk schrieb im Newsbeitrag
news:pan.2004.02.19.15.25.31.227855@adslhome.dk

“Simon Strandgaard” neoneye@adslhome.dk schrieb im Newsbeitrag

Why don’t you just do

def push(choice)
case choice
when Zero, One
@choices << choice
else
raise ArgumentError, "got #{choice.class}"
end
end

a switch statement… easier to read.
However I like to do bailout as soon as possible,
raising ArgumentError this late may make confusion.

What do you mean by “late”? Do you mean that the line with "raise"
stands

below the actual operation. Didn’t think of that, but yes, it might
be

confusing. OTOH, if you can read “case” then it’s not so difficult,
is

it?

It isn’t clear at first sight when the method bailouts, and if
the switch statement spans over many lines, then its not visible at all
that its capable of raising exceptions.

Kind_of? similar to bouncer pattern, see
http://www.rubygarden.org/ruby?BouncerPattern

I see, you want to save the extra method check_arg_xyz(). :slight_smile:

Confusion :slight_smile:

http://lyricsheaven.topcities.com/survey_d_k_bestanden/ELO.htm#confusion

:slight_smile:

def Object#kind_of_any?( *classes )

Yes thought of this… which maked me propose this idea.

I’m wondering though whether it’s worth the effort. When using duck
typing, you don’t need kind_of? anyway.

Btw, I had another idea:

PUSH_ALLOWED = {Zero, One}

def push(choice)
raise ArgumentError, “got #{choice.class}” unless
PUSH_ALLOWED[choice.class]
@choices << choice
end

Good idea, but gives a complex impression at first sight.

Really? PUSH_ALLOWED[choice.class] looks pretty much like a method call
to me… And it’s blindingly fast even for large amounts of classes.
Well, I guess it’s a matter of taste then…

You could also use a Set for this like in

require 'Set’
PUSH_ALLOWED = Set.new([Zero, One])

def push(choice)
raise ArgumentError, “got #{choice.class}” unless
PUSH_ALLOWED.include? choice.class

@choices << choice
end

Did I say there are tons of ways in Ruby? :-))

Of course there is a subtle difference since this does not take sub
classes into consideration. But other than that, it should be
faster -

especially if you have more classes that shoule be checked.

Im in the make it work phase.

There is 3 phases:

  1. make it work
  2. make it right
  3. make it fast :wink:

:-)))

Have fun!

robert
···

On Thu, 19 Feb 2004 16:14:13 +0100, Robert Klemme wrote:

On Thu, 19 Feb 2004 15:43:05 +0100, Robert Klemme wrote:


(Simon Strandgaard) #18

[snip talk about de morgans law]

Yes I know these rules… also karnough maps helps gaining overview of
boolean operations. When an expression gets too complex then I like
place a comment with the corresponding karnough map.

What I should have said was that I grew up with ‘if then else’.
The ‘unless’ keyword is a recent addition to my vocabulary, I am still
a bit rusty in its usage.

···

On Thu, 19 Feb 2004 09:30:16 -0700, Ara.T.Howard wrote:

On Thu, 19 Feb 2004, Simon Strandgaard wrote:

From: Simon Strandgaard neoneye@adslhome.dk
On Thu, 19 Feb 2004 08:19:33 -0700, Ara.T.Howard wrote:

what do you reccomend (when a case won’t do) ?


unless choice.kind_of?(Zero) or choice.kind_of?(One)

My brain is terrible at dealing with ‘unless’.
If its just “unless something” then its ok.
But when its “unless a or b and c” then it chokes.

Am I the only one feeling like this?

Where can I seek help ? :wink:

a digital logic book, the simplest, will help. de morgan’s laws…, eg.

Simon Strandgaard


(Ara.T.Howard) #19

ah. i got it from a the ‘p’ language - one of the good things about it IMHO.
:wink:

-a

···

On Thu, 19 Feb 2004, Simon Strandgaard wrote:

Date: Thu, 19 Feb 2004 18:44:23 +0100
From: Simon Strandgaard neoneye@adslhome.dk
Newsgroups: comp.lang.ruby
Subject: Re: proposal: let kind_of take more arguments

On Thu, 19 Feb 2004 09:30:16 -0700, Ara.T.Howard wrote:

On Thu, 19 Feb 2004, Simon Strandgaard wrote:

From: Simon Strandgaard neoneye@adslhome.dk
On Thu, 19 Feb 2004 08:19:33 -0700, Ara.T.Howard wrote:

what do you reccomend (when a case won’t do) ?


unless choice.kind_of?(Zero) or choice.kind_of?(One)

My brain is terrible at dealing with ‘unless’.
If its just “unless something” then its ok.
But when its “unless a or b and c” then it chokes.

Am I the only one feeling like this?

Where can I seek help ? :wink:

a digital logic book, the simplest, will help. de morgan’s laws…, eg.
[snip talk about de morgans law]

Yes I know these rules… also karnough maps helps gaining overview of
boolean operations. When an expression gets too complex then I like
place a comment with the corresponding karnough map.

What I should have said was that I grew up with ‘if then else’.
The ‘unless’ keyword is a recent addition to my vocabulary, I am still
a bit rusty in its usage.

EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
URL :: http://www.ngdc.noaa.gov/stp/
TRY :: for l in ruby perl;do $l -e “print “\x3a\x2d\x29\x0a””;done
===============================================================================


(Robert) #20

“Simon Strandgaard” neoneye@adslhome.dk schrieb im Newsbeitrag
news:pan.2004.02.19.17.44.22.899443@adslhome.dk

From: Simon Strandgaard neoneye@adslhome.dk

what do you reccomend (when a case won’t do) ?


unless choice.kind_of?(Zero) or choice.kind_of?(One)

My brain is terrible at dealing with ‘unless’.
If its just “unless something” then its ok.
But when its “unless a or b and c” then it chokes.

Am I the only one feeling like this?

Where can I seek help ? :wink:

a digital logic book, the simplest, will help. de morgan’s laws…,
eg.
[snip talk about de morgans law]

Yes I know these rules… also karnough maps helps gaining overview of
boolean operations. When an expression gets too complex then I like
place a comment with the corresponding karnough map.

What I should have said was that I grew up with ‘if then else’.
The ‘unless’ keyword is a recent addition to my vocabulary, I am still
a bit rusty in its usage.

… unless you use it more and more: this will accustom you to the u-word.

:-))

robert
···

On Thu, 19 Feb 2004 09:30:16 -0700, Ara.T.Howard wrote:

On Thu, 19 Feb 2004, Simon Strandgaard wrote:

On Thu, 19 Feb 2004 08:19:33 -0700, Ara.T.Howard wrote: