Txoj kev singleton hauv Ruby yog dab tsi?
Txoj kev singleton hauv Ruby yog dab tsi?

Video: Txoj kev singleton hauv Ruby yog dab tsi?

Video: Txoj kev singleton hauv Ruby yog dab tsi?
Video: Wife Caught Her Husband Marrying Another Woman : WHAT HAPPENED NEXT WILL SHOCK YOU 2024, Kaum ib hlis
Anonim

Singleton txoj kev yog txoj kev uas nyob hauv singleton chav kawm thiab tsuas yog muaj rau ib qho khoom xwb (tsis zoo li qhov piv txwv li niaj zaus txoj kev uas muaj nyob rau txhua qhov piv txwv ntawm chav kawm). Singleton txoj kev feem ntau hu ua chav kawm txoj kev , tab sis qhov tsis meej pem vim Ruby tsis muaj chav kawm txoj kev.

Hauv qhov no, dab tsi yog chav kawm singleton hauv Ruby?

A singleton chav kawm ntawm ib yam khoom (los yog a chav kawm ) yog a chav kawm tsim los ntawm Ruby tsuas yog rau cov khoom tshwj xeeb no. Qhov no chav kawm yog qee yam "zaum" rau peb, tab sis nws nyob ntawd. Thaum hu ib txoj kev ntawm cov khoom no, Ruby yuav saib ua ntej rau hauv nws singleton chav kawm , yog tias muaj ib qho, nrhiav txoj hauv kev ntawd.

Tsis tas li ntawd, txoj kev piv txwv Ruby yog dab tsi? Hauv Ruby , a txoj kev muab functionality rau ib yam khoom. Ib chav kawm txoj kev muab functionality rau chav kawm nws tus kheej, thaum ib piv txwv txoj kev muab functionality rau ib tug piv txwv ntawm ib chav kawm.

Ntawm no, Eigenclass yog dab tsi hauv Ruby?

Eigenclass hauv ruby . Rau kuv, " Eigenclass "yog lub npe txawv. Ntawm no yog lub ntsiab txhais ntawm " Eigenclass ” los ntawm wikipedia: Ib chav zais zais cuam tshuam nrog txhua qhov tshwj xeeb ntawm lwm chav kawm. Txij li thaum "txoj kev zoo li qub" lossis "txoj kev hauv chav kawm" yog qhov tseeb singleton txoj kev ntawm ib chav kawm tshwj xeeb.

Vim li cas txhua yam yog khoom hauv Ruby?

" Txhua yam hauv Ruby yog ib Yam khoom "yog ib yam uas koj yuav hnov ntau zaus. Lub hom phiaj ntawm no yog rau koj kom pom Matrix ntawd txhua yam hauv Ruby yog ib Yam khoom , txhua khoom muaj chav kawm, thiab ua ib feem ntawm chav kawm ntawd muab rau khoom Muaj ntau txoj hauv kev uas nws tuaj yeem siv los nug cov lus nug lossis ua tej yam.

Pom zoo: