Feature #14347 » 0001-Describe-difference-between-Symbol-and-String-classe.patch
string.c | ||
---|---|---|
/**********************************************************************
|
||
* Document-class: Symbol
|
||
*
|
||
* <code>Symbol</code> objects represent names and some strings
|
||
* <code>Symbol</code> objects represent named identifiers
|
||
* inside the Ruby
|
||
* interpreter. They are generated using the <code>:name</code> and
|
||
* <code>:"string"</code> literals
|
||
... | ... | |
* $f2.object_id #=> 2514190
|
||
* $f3.object_id #=> 2514190
|
||
*
|
||
* Constant, method, and variable names are returned as symbols:
|
||
*
|
||
* module One
|
||
* Two = 2
|
||
* def three; 3 end
|
||
* @four = 4
|
||
* @@five = 5
|
||
* $six = 6
|
||
* end
|
||
* seven = 7
|
||
*
|
||
* One.constants
|
||
* # => [:Two]
|
||
* One.instance_methods(true)
|
||
* # => [:three]
|
||
* One.instance_variables
|
||
* # => [:@four]
|
||
* One.class_variables
|
||
* # => [:@@five]
|
||
* global_variables.last
|
||
* # => :$six
|
||
* local_variables
|
||
* # => [:seven]
|
||
*
|
||
* Symbol objects are different from String objects in that
|
||
* Symbol objects represent identifiers, while String objects
|
||
* represent text or data.
|
||
*/
|
||
... | ... | |
/*
|
||
* A <code>String</code> object holds and manipulates an arbitrary sequence of
|
||
* bytes, typically representing characters. String objects may be created
|
||
* using <code>String::new</code> or as literals.
|
||
* bytes, typically representing text or binary data. String objects may be
|
||
* created using <code>String::new</code> or as literals.
|
||
*
|
||
* <code>String</code> objects differ from <code>Symbol</code> objects in that
|
||
* <code>Symbol</code> objects are designed to be used as identifiers, instead
|
||
* of text or data.
|
||
*
|
||
* Because of aliasing issues, users of strings should be aware of the methods
|
||
* that modify the contents of a <code>String</code> object. Typically,
|
- « Previous
- 1
- 2
- Next »