1 Replies - 522 Views - Last Post: 02 October 2013 - 07:45 PM Rate Topic: -----

#1 Komputerkid  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 02-October 13

Problem with .include? and filling an Array

Posted 02 October 2013 - 11:34 AM

I am trying to fill an array with the question numbers of the questions the student answered incorrectly. I know there's a bug in my code I just can't quite figure it out. missedquestions array needs to skip for every correct answer. Any help is appreciated, Thanks


20.times do 
print_question(n)
print "Answer:"
studentsAnswer<<gets.chomp




if testAnswerfile[compareCount].include?(studentsAnswer[compareCount])  
	puts "Correct"
	correct += 1
else
	puts "Incorrect"
	missed_questions << a
	missed += 1 
	
	
end 
		n +=1
		a +=1
		compareCount+=1
		count = 1
			
end






Is This A Good Question/Topic? 0
  • +

Replies To: Problem with .include? and filling an Array

#2 xclite  Icon User is offline

  • LIKE A BOSS
  • member icon


Reputation: 902
  • View blog
  • Posts: 3,163
  • Joined: 12-May 09

Re: Problem with .include? and filling an Array

Posted 02 October 2013 - 07:45 PM

It's helpful if you describe how the program isn't working like you'd expect - you "know there's a bug" but you didn't describe the symptoms to us.

The code you've provided isn't quite syntactically correct, to be honest. What is 'n' in line 2?
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1