Created
August 7, 2010 23:51
-
-
Save emiltin/513344 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class Integer | |
| def divisable? v,b | |
| "#{v%b==0 ? '' : 'not '}dividable by #{b}" | |
| end | |
| def show_divisors *a | |
| info = a.map { |n| "is #{divisable? self,n}" }.join ' and ' | |
| puts "The value #{self} #{info}." | |
| end | |
| end | |
| 1.upto(10) { |x| x.show_divisors 3,5 } | |
| 1.upto(10) { |x| x.show_divisors 3,5,7,9 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment