We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bit confuse about String Literal in Ruby.
String Literal
What is String? Object in Ruby.
What is Literal? The value appears directly in Ruby code.
Example:
╰─$ irb 2.4.0 :005 > 5.times { a = 'test'; puts a.object_id; } 70105430666100 70105430665960 70105430665840 70105430665760 70105430665700 => 5 2.4.0 :006 > 5.times { a = 'test'.freeze; puts a.object_id } 70105426108320 70105426108320 70105426108320 70105426108320 70105426108320 => 5
According to The Ruby Programming Language book:
For efficiency, you should avoid using literals within loops.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Problem:
Bit confuse about
String Literal
in Ruby.Solution:
What is String?
Object in Ruby.
What is Literal?
The value appears directly in Ruby code.
Example:
Lesson:
According to The Ruby Programming Language book:
The text was updated successfully, but these errors were encountered: