mardi 5 mai 2015

Convert sample java code to ruby to understand static variales in ruby

can anybody help me to convert this simple java code to ruby.

class A {
 private static String[] chachedNames;

 public static String[] getNames(){
  if(chachedNames == null)
   chachedNames = prepareNames(); //This process will take 20sec to complete
  return chachedNames;
 }
}

I'm trying to understand basic memory caching on static method. How do implement same on Ruby.

Aucun commentaire:

Enregistrer un commentaire