Project

General

Profile

Feature #14347 ยป 0001-Describe-difference-between-Symbol-and-String-classe.patch

jeremyevans0 (Jeremy Evans), 01/10/2018 05:14 AM

View differences:

string.c
10284 10284
/**********************************************************************
10285 10285
 * Document-class: Symbol
10286 10286
 *
10287
 *  <code>Symbol</code> objects represent names and some strings
10287
 *  <code>Symbol</code> objects represent named identifiers
10288 10288
 *  inside the Ruby
10289 10289
 *  interpreter. They are generated using the <code>:name</code> and
10290 10290
 *  <code>:"string"</code> literals
......
10312 10312
 *     $f2.object_id   #=> 2514190
10313 10313
 *     $f3.object_id   #=> 2514190
10314 10314
 *
10315
 * Constant, method, and variable names are returned as symbols:
10316
 *
10317
 *     module One
10318
 *       Two = 2
10319
 *       def three; 3 end
10320
 *       @four = 4
10321
 *       @@five = 5
10322
 *       $six = 6
10323
 *     end
10324
 *     seven = 7
10325
 *
10326
 *     One.constants
10327
 *     # => [:Two]
10328
 *     One.instance_methods(true)
10329
 *     # => [:three]
10330
 *     One.instance_variables
10331
 *     # => [:@four]
10332
 *     One.class_variables
10333
 *     # => [:@@five]
10334
 *     global_variables.last
10335
 *     # => :$six
10336
 *     local_variables
10337
 *     # => [:seven]
10338
 *
10339
 * Symbol objects are different from String objects in that
10340
 * Symbol objects represent identifiers, while String objects
10341
 * represent text or data.
10315 10342
 */
10316 10343

  
10317 10344

  
......
10770 10797

  
10771 10798
/*
10772 10799
 *  A <code>String</code> object holds and manipulates an arbitrary sequence of
10773
 *  bytes, typically representing characters. String objects may be created
10774
 *  using <code>String::new</code> or as literals.
10800
 *  bytes, typically representing text or binary data. String objects may be
10801
 *  created using <code>String::new</code> or as literals.
10802
 *
10803
 *  <code>String</code> objects differ from <code>Symbol</code> objects in that
10804
 *  <code>Symbol</code> objects are designed to be used as identifiers, instead
10805
 *  of text or data.
10775 10806
 *
10776 10807
 *  Because of aliasing issues, users of strings should be aware of the methods
10777 10808
 *  that modify the contents of a <code>String</code> object.  Typically,
10778
-