In Java eine ‚statische Methode‘ würde wie folgt aussehen:Wie sieht eine statische Java-Methode in Ruby aus?
class MyUtils {
. . .
public static double mean(int[] p) {
int sum = 0; // sum of all the elements
for (int i=0; i<p.length; i++) {
sum += p[i];
}
return ((double)sum)/p.length;
}
. . .
}
// Called from outside the MyUtils class.
double meanAttendance = MyUtils.mean(attendance);
Was ist das Äquivalent ‚Ruby Weg‘ eine ‚statische Methode‘ zu schreiben?
wow traf nie ein Pferd, das moo sagte: P –
Es ist ein ganz besonderes Pferd :) – aoj
@Nathan W: Ich dachte, dass [Horse] (http://en.wikipedia.org/wiki/Footrot_Flats#Main_characters) miau ging. –