Hi all,
please, is there a way to pre-determine the size (or capacity) of a
string in ruby?
i.e if a have a string “str” , i will set it to contain characters not
more than 10.
Hi all,
please, is there a way to pre-determine the size (or capacity) of a
string in ruby?
i.e if a have a string “str” , i will set it to contain characters not
more than 10.
PLEASE DO NOT SHOUT.
2010/6/2 kevid [email protected]:
please, is there a way to pre-determine the size (or capacity) of a
string in ruby?i.e if a have a string “str” , i will set it to contain characters not
more than 10.
No, strings in Ruby are unbounded. If you need that functionality you
will have to create a class which implements this.
(Note: Ruby != C)
Kind regards
robert
kevid wrote:
please, is there a way to pre-determine the size (or capacity) of a
string in ruby?
Nope, strings are resized dynamically as required. But you could make
your own class which does this.
It could, for example, delegate to an underlying String object,
intercepting calls which could make the string bigger, and either raise
an error or truncate the error if it exceeds the chosen size.
On 2 June 2010 17:20, Brian C. [email protected] wrote:
But you likely do not need that
What is your aim ?
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs