जावा में, एक 'स्थिर विधि' इस प्रकार दिखाई देगा:रूबी में जावा स्थैतिक विधि कैसी दिखती है?
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);
बराबर एक 'स्थिर विधि' लिखने की 'रूबी रास्ता' क्या है?
वाह एक घोड़ा ही कहा मू कभी नहीं मिला: पी –
यह एक बहुत ही खास घोड़ा है :) – aoj
@ नाथन डब्ल्यू: मैंने सोचा कि [घोड़ा] (http://en.wikipedia.org/wiki/Footrot_Flats#Main_characters) मियाओ चला गया। –