SORU
11 EKİM 2010, PAZARTESİ


Ruby sınıf türleri ve case ifadeleri

Ne arasındaki farktır

case item.class
when MyClass
  # do something here
when Array
  # do something different here
when String
  # do a third thing
end

ve

case item.class
when MyClass.class
  # do something here
when Array.class
  # do something different here
when String.class
  # do a third thing
end

Nedense, bazen çalışır ve ikinci bu ilk değil, ve diğer zamanlarda değil, ikinci bir eser ve ilk değil. Neden? "Doğru" yol yapmak için mi? hangisi

CEVAP
11 EKİM 2010, PAZARTESİ


Kullanmanız gerekir:

case item
    when MyClass

Aynı sorun bende de vardı: http://stackoverflow.com/questions/3801469/how-to-catch-errnoeconnreset-class-in-case-when

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • BrandonHarrisWalker

    BrandonHarri

    27 Kasım 2006
  • EatingIn

    EatingIn

    12 EKİM 2013
  • ethr95awd

    ethr95awd

    8 Kasım 2006