init
This commit is contained in:
commit
1c02f1f789
19
fact.rb
Normal file
19
fact.rb
Normal file
@ -0,0 +1,19 @@
|
||||
# factorializer!
|
||||
|
||||
def fact(n)
|
||||
if n == 0
|
||||
return 1
|
||||
else
|
||||
return n * fact(n - 1)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def main()
|
||||
puts fact(ARGV[0].to_i)
|
||||
end
|
||||
|
||||
|
||||
if __FILE__ == $0
|
||||
main()
|
||||
end
|
31
hello.rb
Normal file
31
hello.rb
Normal file
@ -0,0 +1,31 @@
|
||||
=begin
|
||||
|
||||
OMG this be my comment
|
||||
|
||||
|
||||
=end
|
||||
|
||||
|
||||
class Greeter
|
||||
def initialize(name="World")
|
||||
@name = name
|
||||
end
|
||||
def say_hi
|
||||
puts "Hi #{@name}!"
|
||||
end
|
||||
def say_bye
|
||||
puts "Bye #{@name}, y'all come back now."
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def main
|
||||
grt = Greeter.new("Fizzle")
|
||||
grt.say_hi()
|
||||
grt.say_bye()
|
||||
end
|
||||
|
||||
|
||||
if __FILE__ == $0
|
||||
main()
|
||||
end
|
Loading…
Reference in New Issue
Block a user