Permalink
Browse files

Merge pull request #19 from bobbyno/arrays

Add new Array drills
  • Loading branch information...
bobbyno committed Feb 13, 2017
2 parents 00909bf + 4895bb1 commit 07756d79239547bffbe49245e484a75823b7a36e
Showing with 49 additions and 1 deletion.
  1. +24 −0 lib/ruby_drills/array/delete_drill.rb
  2. +24 −0 lib/ruby_drills/array/uniq_drill.rb
  3. +1 −1 lib/ruby_drills/version.rb
@@ -0,0 +1,24 @@
class DeleteDrill < Drill
def setup
@values = [ "a", "b", "b", "b", "c" ]
@hints = ["It's the method you think it is!",
"https://ruby-doc.org/core-2.3.0/Array.html#method-i-delete"]
end
def show
puts %{
@values = #{@values.inspect}
Use a method to delete "b" from the array of values.
}
end
def reference
"@values.delete(\"b\")"
end
def valid?(input)
input.include?("delete(\"b\")")
end
end
@@ -0,0 +1,24 @@
class UniqDrill < Drill
def setup
@shopping_list = [ "apples", "oranges", "grapes", "bananas", "toothpaste", "bread", "apples", "oranges" ]
@hints = ["You do not need to search the array, use a method that does that for you.",
"https://ruby-doc.org/core-2.3.0/Array.html#method-i-delete"]
end
def show
puts %{
@shopping_list = #{@shopping_list.inspect}
I need my shopping_list to contain unique items.
}
end
def reference
"@shopping_list.uniq"
end
def valid?(input)
input.include?("uniq")
end
end
@@ -1,3 +1,3 @@
module RubyDrills
VERSION = "0.2.0"
VERSION = "0.3.0"
end

0 comments on commit 07756d7

Please sign in to comment.