Otra más:

> res = [/\xc3\x81/, /\303\201/, /Á/]
=> [/\xc3\x81/, /\303\201/, /\303\201/]
> res.map &:hash
=> [527397363, -279873034, 141541]
> res.each {|re| re =~ "hola"}
=> [/\xc3\x81/, /\303\201/, /\303\201/]
> res.map &:hash
=> [404259843, -403010554, 141541]

y

irb(main):014:0> res = [/\xc3\x81/u, /\303\201/u, /Á/u]
=> [/\xc3\x81/u, /\303\201/u, /\303\201/u]
> res.map &:hash
=> [527397363, -279873034, 429037]
> res.each {|re| re =~ "hola"}
=> [/\xc3\x81/u, /\303\201/u, /\303\201/u]
> res.map &:hash
=> [404259843, -403010554, 429037]

Solo la versión con 'Á' cambia de hash al usar 'u' como modificador.

2009/7/10 Bruno Deferrari <[email protected]>:
> 2009/7/10 Pablo Herrero <[email protected]>:
>> Lo unico que creo q deberia de considerase bug es que /\303\200/u != /À/u
>
> Mirate esto:
>
> irb(main):001:0> [/\303\201/.source, /Á/.source]
> => ["\\303\\201", "\303\201"]
>
> La documentación dice:
> "Equality—Two regexps are equal if their patterns are identical, they
> have the same character set code, and their casefold? values are the
> same."
>
> Mi pregunta es, deberían considerarse idénticos (que no es lo mismo
> que equivalentes) esos 2 patrones?
>
_______________________________________________
Ruby mailing list
[email protected]
http://lista.rubyargentina.com.ar/listinfo.cgi/ruby-rubyargentina.com.ar

Responder a