I'm trying to write a function that will remove an array from a 3d array where an array has a matching String name.
before(:each) do
@topic1 = Topic.new 4,'topic 1'
@topic2 = Topic.new 7,'topic 2'
@topic3 = Topic.new 5,'topic 3'
@subject = Subject.new 'Module 1',2,5
end
parameters are No_of_Lectures and Name
@topics = [5,'Topic1'], [3,'Topic2'], [5,'Topic3']
Basically I'd like to remove the array where Name = 'Topic1' or return null if it's not in the list.
What I have so far is
def findTopic name
@topics.find {|topic| topic.name == name }
end
def removeTopic name_in
if @topics.findTopic(name)
@topics.delete_if {|key, name| name == name_in }
topic
else
null
end
end
topicisn't defined in the method, so it wouldn't even run (unless it's a method as well).