Initialize a counter for all possible values
This commit is contained in:
parent
03b3e18126
commit
08fe4163bc
1 changed files with 3 additions and 0 deletions
3
mj.rb
3
mj.rb
|
|
@ -13,6 +13,9 @@ class MajorityJudgment
|
|||
if arg.is_a?(Array)
|
||||
@ratings = arg
|
||||
@count = { }
|
||||
self.class.values.each do |v|
|
||||
@count[v[:id]] = 0
|
||||
end
|
||||
@n = 0
|
||||
ratings.each do |r|
|
||||
@count.has_key?(r) ? @count[r] = @count[r] + 1 : @count[r] = 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue