Created
December 14, 2012 02:29
-
-
Save big-samantha/4282056 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# print a string | |
puts 'Let\'s practice everything.' | |
# print another string. | |
puts 'You\'d need to know \'bout excapes with \\ that do \n newlines and \t tabs.' | |
# preformatted multiline string. only exception is that it can use escape chars | |
# saved to variable | |
poem = <<MULTI_LINE_STRING | |
\tThe lovely world | |
with logic so firmly planted | |
cannot discern \n the needs of love | |
nor comprehend passion from intuition | |
and requires an explanation | |
\n\twhere there is none. | |
MULTI_LINE_STRING | |
# print out the poem variable which contains a multiline preformatted | |
# string | |
puts '----------------' | |
puts poem | |
puts '----------------' | |
# set variable 5 equal to non-floating number result of 10 - 2 + 3 - 6 | |
five = 10 - 2 + 3 - 6 | |
# print results | |
puts "This should be five: #{five}" | |
# create a function called secret_formula | |
# declare variable started as part of that formula | |
# return as final values, jelly_beans, jars and crates variables. | |
def secret_formula(started) | |
jelly_beans = started * 500 | |
jars = jelly_beans / 1000 | |
crates = jars / 100 | |
return jelly_beans, jars, crates | |
end | |
start_point = 10000 | |
beans, jars, crates = secret_formula(start_point) | |
puts "With a starting point of: #{start_point}: | |
puts "We'd have #{beans} beans, #{jars} jars, and #{crates} creates." | |
start_point = start_point / 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment