.to_i
- Casts to int by dropping anything after decimal point from a float, no rounding.to_f
- Casts to float.to_s
- Casts to string.to_sym
- Casts to symbol
- Use
+
,<<
or.concat()
to concatenate strings "hello"[0..1]
# =>"he"
"hello"[0, 4]
# =>"hell"
"hello"[-1] # =>
"o"`
\\ #=> backslash
\b #=> backspace
\r #=> carriage return
\n #=> newline
\s #=> space
\t #=> tab
\" #=> double quotation
\' #=> single quotation
name = "Mark"
puts "Oh, hi #{name}!" #=> "Oh, hi Mark!"
puts 'Oh, hi #{name}!' #=> "Oh, hi #{name}!"
- Must use double quotation marks for string interpolation to work!