Basic Ruby

Estimated reading time: 1 minute

comments

# Single line comments
=begin
This is multi line comment with begin and end
=end
  • puts print with a new line
  • print print only with one line

String

puts 'single qoute string'
puts "Double qoute string"

symbol

  • : symbol keyword
  • fixed object id
name = :'mostafa'
name2 = 'mostafa'

puts name.object_id
puts name2.object_id

boolean

  • true
  • false

~ 0 and 1 is not boolean

upcase

name = "mostafa"
puts name.upcase()
# MOSTAFA

downcase

name = "Mostafa"
puts name.downcase()
# mostafa
ruby