I notice in recent commits that a number of these have been added:

    /\[(\d+)\]/.freeze

I thought that Regexps are immutable. Furthermore, Regexp literals don't
generate a new object each time they are encountered:

irb(main):001:0> 3.times { puts /\d+/.object_id }
-605707646
-605707646
-605707646
=> 3
irb(main):002:0>

Unlike strings:

irb(main):002:0> 3.times { puts "abc".freeze.object_id }
-605884514
-605884594
-605884674
=> 3

So, could someone please explain why .freeze is beneficial on regexp
literals?

Thanks,

Brian.
_______________________________________________
Merb-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/merb-devel

Reply via email to