fine, thanks, difficult to catch out typos particularly in regexps...
Try this:
[...]
flag=(rgx === truc) # /// switch these around
p "flag = #{flag}"
# => "flag = true"
i did both :
flag=(truc === rgx)
p "flag = #{flag} for flag=(truc === rgx)"
# => "flag = false for flag=(truc === rgx)""
flag=(rgx === truc)
p "flag = #{flag} for flag=(rgx === truc)"
# => "flag = true for flag=(rgx === truc)"
that's a really strange behaviour, to me, of ruby, a "symetrical"
operator symbol being not commutative ???
better to know
See also the 'what on earth...' thread that's been on the list recently
(yesterday/today I think).
ok, thanks very much !
···
Ross Bamford <rossrt@roscopeco.co.uk> wrote:
--
une bévue
Adding to Ross' excellent explanation: it helps to *not* view "===" as an equality operator. Rather it's a general matching operator, whatever matching means in a certain context. For RX it will do an RX match, for class objects it will do the kind_of? check, for a range it will check include? etc. Btw, has anyone an idea why this does not apply to Enumerable?
Adding to Ross' excellent explanation: it helps to *not* view "===" as
an equality operator. Rather it's a general matching operator, whatever
matching means in a certain context. For RX it will do an RX match, for
class objects it will do the kind_of? check, for a range it will check
include? etc. Btw, has anyone an idea why this does not apply to
Enumerable?
[1,2,3].include? 2
=> true
[1,2,3] === 2
=> false
It would be nice, but then how would this work:
irb(main):001:0> case [1,2,3]
irb(main):002:1> when [1,2,3]
irb(main):003:1> puts "same array!"
irb(main):004:1> end
same array!
=> nil
···
On Thu, 2006-03-23 at 23:13 +0900, Une bévue wrote:
--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
Adding to Ross' excellent explanation: it helps to *not* view "===" as
an equality operator. Rather it's a general matching operator, whatever
matching means in a certain context. For RX it will do an RX match, for
class objects it will do the kind_of? check, for a range it will check
include? etc. Btw, has anyone an idea why this does not apply to
Enumerable?
[1,2,3].include? 2
=> true
[1,2,3] === 2
=> false
It would be nice, but then how would this work:
irb(main):001:0> case [1,2,3]
irb(main):002:1> when [1,2,3]
irb(main):003:1> puts "same array!"
irb(main):004:1> end
same array!
=> nil
···
On Thu, 2006-03-23 at 23:13 +0900, Une bévue wrote:
--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
I'm trying to use builder to construct jnlp files. I need to create elements with "-" in the name and can't. For example I need to output the following xml fragment:
<security>
<all-permissions />
</security>
Here's what I tried with builder:
x = Builder::XmlMarkup.new(:target => $stdout, :indent => 1)
x.security {
x.all-permissions
}
but the "-" is parsed in the name and this produces a NameError
NameError: undefined local variable or method `permissions' for main:Object