From: Pavel Rosputko Date: 2010-12-22T05:01:20+09:00 Subject: [ruby-core:33802] [Ruby 1.9-Feature#4184][Open] String that has the same object_id in an each occurrence in a code Feature #4184: String that has the same object_id in an each occurrence in a code http://redmine.ruby-lang.org/issues/show/4184 Author: Pavel Rosputko Status: Open, Priority: Normal Regexp literals: 5.times { p /abcdasdf/.object_id } -> same! String literals: 5.times { 'asdasdf'.object_id } -> different Propose: 5.times { %c(asdasdf).object_id } -> same! Example of usefullness: a,b,c,d = data.unpack %c(ccNc) | e,f,g,h = a.unpack %c(cvaN) | repeated many times Aspects: - String like 'ccNc' are created many times - Not modified - Used once in code It is possible to write "class K; Format_ccNc = 'ccNc'; end" but Format_ccNc will be used only once! It is logical to make %c() strings frozen. ---------------------------------------- http://redmine.ruby-lang.org