Skip to content

Instantly share code, notes, and snippets.

# This function will break up words for us.
def break_words(stuff)
words = stuff.split(' ')
return words
end
# Sorts the words.
def sort_words(words)
return words.sort
end
module Ex26
# This function will break up words for us.
def Ex26.break_words(stuff)
words = stuff.split(' ')
return words
end
# Sorts the words.
def Ex26.sortwords(words)
module Ex25
# This function will break up words for us.
def Ex25.break_words(stuff)
words = stuff.split(' ')
return words
end
# Sorts the words.
def Ex25.sort_words(words)
def Ex25.sort_words(words)
return words.sort
end
@Dasms
Dasms / error
Created November 11, 2017 00:43
words = Ex25.break_words(sentence)
SystemStackError: stack level too deep
# Just 1 argument
def print_one(arg1)
puts "arg1: #{arg1}"
end
# this one is just like your scripts with ARGV
def print_two(*args)
arg1, arg2 = args
puts "arg1: #{arg1}, arg2: #{arg2}"
end
# That *args is actually pointless, we can just do this:
def print_two_again(arg1, arg2)
puts "arg1: #{arg1}, arg2: #{arg2}"
end
Copying data from test1.txt,test2.txt to .
ex17.rb:5:in `initialize': No such file or directory @ rb_sysopen - test1.txt,test2.txt (Errno::ENOENT)
from ex17.rb:5:in `open'
from ex17.rb:5:in `<main>'
prices = {
"tennis ball" => 4.99,
"beach ball" => 12.99,
"giraffe" => 93.86,
}
print "What is your name? "
name = gets.chomp
print "What is your name? "
name = gets.chomp
puts "Alright #{name} what would you like to buy today?
We currently have a beach ball, a tennis ball and a giraffe.
The beach ball is 12.99, the tennis ball is 4.99 and the
giraffe is 93.86. You currently have $120. "
purchase = gets.chomp
if purchase == "tennis ball"
price = 4.99