[MacRuby-devel] Potential macirb issue

Mark Rada mrada at marketcircle.com
Thu Mar 10 12:01:11 PST 2011


Hey all,

I am getting an error when I add a #to_s method to NSURL:
	
	 ± irb
	irb(main):001:0> class NSURL
	irb(main):002:1>   alias_method :to_s, :absoluteString
	irb(main):003:0> end
	=> NSURL
	irb(main):004:0> NSURL.URLWithString( 'macruby.org' )
	RuntimeError: can't modify frozen/immutable string
	
	irb(main):005:0> test = NSURL.URLWithString( 'macruby.org' )
	RuntimeError: can't modify frozen/immutable string
	
	irb(main):006:0> test.to_s
	=> "macruby.org"
	irb(main):007:0> 

So the error seems to be macirb trying to do something to the string that is returned from #to_s.

I'm not sure if this is unique to MacRuby, as the CRuby documentation for Object#to_s doesn't say whether the returned object should be frozen, but should I be making #to_s return a mutable/unfrozen string?


Mark Rada
mrada at marketcircle.com





More information about the MacRuby-devel mailing list