Ruby Strings
Table of Contents

Introduction

Strings are objects of class String.

Examples

Example 1: The value returned by a Ruby method is the value of the last expression evaluated.

def say_goodnight(name)  
  result = "Good night, #{name}"  
  return result  
end  
puts say_goodnight('chrys')  
 
# modified program  
def say_goodnight2(name)  
  "Good night, #{name}"  
end  
puts say_goodnight2('chrys')
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.