Permalink
Browse files

fibonacci example

  • Loading branch information...
1 parent 471c579 commit 52d9be2c881aee8a33b6a60ebcff622bd900bc18 @coreyhaines committed Nov 7, 2008
Showing with 16 additions and 0 deletions.
  1. +16 −0 README.txt
View
@@ -24,6 +24,22 @@ overload_method :even_odd do |m|
end
However, this syntax may or may not be deprecated in favor of the when/do syntax.
+Here's an example of Fibonacci calculation:
+class CalculatesFibonacci
+
+ class << self
+ include OverloadedMethods
+ overload_method :entry do |m|
+ m.when{|which| which <= 1}.do{|which| which}
+ m.default{|which|
+ CalculatesFibonacci.entry(which-1) + CalculatesFibonacci.entry(which-2)
+ }
+ end
+ end
+end
+
+
+
== FEATURES/PROBLEMS:
* FIX (list of features or problems)

0 comments on commit 52d9be2

Please sign in to comment.