Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # DATA TYPES
- # INTEGER
- # 2
- # 100029
- # STRING
- # "Hello"
- # ""
- # " "
- # Interpolation
- name = "joao"
- age = 27
- "Hello #{name}, #{age}"
- # Concatenation
- "Hello " + name + ", " + age.to_s
- # Single vs Double quotes
- # puts "hello #{2 + 7}"
- # puts 'hello #{2 + 7}'
- # FLOAT
- # 3.14
- # 1.2343
- 3.14.floor
- 3.14.ceil
- 3.14.truncate
- # ARRAY
- # List of elements
- beatles = ["john", "paul", "ringo", "george"]
- beatles.sort
- beatles.count
- # NIL
- nil
- # absence of value
- # BOOLEANS
- true.class # => TrueClass
- false.class # => FalseClass
- # RANGE
- # (1..5) # range from 1 to 5
- # (1...5) # range from 1 to 4
- # Casting (changing the data type)
- # "1991".to_i # => 1991
- # "1991".to_f # => 1991.0
- # (1..5).to_a # => [1,2,3,4,5]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement