Coder Profile - Show off your skills, get a coder profile.
 
 
 
code pin board using strings in Ruby Download Source Code
Author Details Code Information
Damner ( Dominik )

Pinned 3 Codes
Posted 1 Coding Articles

Send A Message
View Coders Profile
Language Plain Text
Expires Never
Length 704 Characters (19 Lines)
Password no password
Description

About Ruby Strings
  1. =begin
  2. Ruby Strings
  3. In Ruby, strings are mutable
  4. =end
  5.  
  6. puts "Hello World"
  7. # Can use " or ' for Strings, but ' is more efficient
  8. puts 'Hello World'
  9. # String concatenation
  10. puts 'I like' + ' Ruby'
  11. # Escape sequence
  12. puts 'It\'s my Ruby'
  13. # New here, displays the string three times
  14. puts 'Hello' * 3
  15. # Defining a constant
  16. PI = 3.1416
  17. puts PI
  18. #The command output string is sent to the operating system as a command to be executed (under windows operating system, we have sent the dir command), whereupon the output of the command (dir on a command window would display all the files and sub directories in your folder) is then displayed by puts.
  19. puts `dir`
code pin board Back To Code Pin Board Post New Code
Please login to post comments.
 
Damner     Posted 201 Days Ago
 
 
check out this page:
http://ruby.about.com/od/learnruby/qt/strings.htm

Truth be told, the quotes don't really matter if your doing simple stuff like
this but later on its got to do with escape characters and string interpolation. The
quotes themselves only have one main difference that is memory allocation, from what
I understand the double quotes allocate more of it then the single quotes.
 
remy     Posted 207 Days Ago
 
 
in PHP, the single-quote is treated as plain-text, whereas the double-quote is
actually parsed. I'm not sure if this is the same for Ruby. how is the
single-quote more efficient?
 
Cinjection     Posted 214 Days Ago
 
 
Good stuff. Keep going. Ruby has a lot of really cool features.
Page 1 of 1
 
 
Part of the MyPingle Network
Development Blog :: Make A Donation :: Contact Me
Terms & Conditions :: Privacy Policy :: Documents
Version 1.44.00
Copyright © 2007 - 2008, Scott Thompson, All Rights Reserved