Count and instances | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

Count and instances

In Ruby, can anyone recommend a better way to count instances and track details of all instances? What I typically do is define class variables @@count = 0 and @@instances = [] and use @@count += 1 and @@instances << self under initialize. Thanks!

26th Dec 2017, 6:06 AM
Ken Kelley
Ken Kelley - avatar
0 Réponse