[ create a new paste ] login | about

Link: http://codepad.org/onXk3vMW    [ raw code | output | fork ]

Ruby, pasted on Jun 20:
# Strings

puts 'Hello, world!'

# short_string = "Amazing!"

# what = "This is a string. A string can be between single or double quotes in this language."

# cool = "You can add strings together or you can insert other variables into specfic parts of a string using string interpolation, like this: #{short_string}"

# puts cool

# pos = "strings are able to be indexed, starting with zero. You can access them with brackets []"

# puts pos[0], pos[5], pos[0,5]

# loops = 'You can loop through a string letter by letter, then perform logic on each character'

# loops.each_char do |character|
#   if character == "e"
#     puts "another e!"
#   end
# end

# Integers and Floats
# num = 1
# random_float = 2.7

# puts num + random_float

# num += 1
# puts num

# num = num + 3
# puts num

# puts num.to_s + "yo"

# puts "37".to_i + 1
# puts "38.9".to_f + 1.7

# (2..8).each do |e| 
#   puts e
# end

# Booleans
# puts true && false, true == (3 == 2+1)

# Arrays (lists)
# fruit = ["banana", "strawberry", "apples"]
# lucky_nums = [7, 23, 19]
# nested = [["what", "huh"], ["cool", "nice"], ["this", "that"]]


Output:
1
Hello, world!


Create a new paste based on this one


Comments: