Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Whats the difference between symbol and string?

Answer Posted / abhishek shukla

Symbol refers to the same memory location where string
generates a new id every time for eg.

STRING
irb(main):019:0> "ruby".object_id
=> 24095860
irb(main):020:0> "ruby".object_id
=> 24092310
irb(main):021:0> "ruby".object_id
=> 24088760
irb(main):022:0>

SYMBOL
irb(main):022:0> :ruby.object_id
=> 102978
irb(main):023:0> :ruby.object_id
=> 102978
irb(main):024:0> :ruby.object_id
=> 102978
irb(main):025:0> :ruby.object_id
=> 102978
irb(main):026:0>

Is This Answer Correct ?    23 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of $ in ruby?

878


What is the main difference between procs and blocks?

942


Mention the differences between the observers and callbacks in ruby on rails.

903


What is the difference between false and nil in ruby?

927


How many types of relationships does a model has?

882


How you run your rails application without creating databases?

939


what is sweeper in Rails?

962


What are gemsets in rails?

840


what is active record?

957


Where does the start_tabnav gets informations for tabs rendering in ruby rail?

899


What I have to do to view my project always on browser?

915


Explain valid and invalid in rails?

877


What do you mean by render and redirect_to?

923


Write a program to generate and run the application without the use of database

868


How would you create a controller for the subject?

869