Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

8-3

  • Loading branch information...
commit 31daa723de3979467f6030be2d4c9cf2732cf10a 1 parent e772ddf
@liweinan authored
Showing with 13 additions and 0 deletions.
  1. +13 −0 ruby/cookbook/8-3.rb
View
13 ruby/cookbook/8-3.rb
@@ -0,0 +1,13 @@
+def append_to_self(x)
+ unless x.respond_to? :<<
+ raise ArgumentError, "Method not supported"
+ end
+ if x.is_a? Numeric
+ raise ArgumentError, "Numeric not supported"
+ end
+ x << x
+end
+
+puts append_to_self('abc')
+puts append_to_self([1,2,3])
+

0 comments on commit 31daa72

Please sign in to comment.
Something went wrong with that request. Please try again.