Ben bir nesne ile neler yöntemleri ve alanları görebilir?Python'un dir() ile Groovy eşdeğeri nedir?</p> <pre><code>print dir(my_object) </code></pre> <p>Groovy bunun eşdeğeri (birine sahip varsayarak) Neler: Python
7
A
cevap
8
Groovy özellikle hoş görünüyor (denenmemiş, taken from this link böylece kod kredi oraya gitmeli):
// Introspection, know all the details about classes :
// List all constructors of a class
String.constructors.each{println it}
// List all interfaces implemented by a class
String.interfaces.each{println it}
// List all methods offered by a class
String.methods.each{println it}
// Just list the methods names
String.methods.name
// Get the fields of an object (with their values)
d = new Date()
d.properties.each{println it}
Aradığınız genel bir terimdir introspection olduğunu.
4
As String nesnesi için tanımlanan tüm yöntemleri bulmak için, here tarif:
"foo".metaClass.methods*.name.sort().unique()
belki başkası daha iyi bir yol gösterebilir, Python sürümü kadar basit değil.
0
sadece normal bir Java yansıma API kullanarak yanı sıra, var: Ayrıca metaclasses oyun oynayan
http://docs.codehaus.org/display/GROOVY/JN3535-Reflection
.
İlgili konular
- 1. Bu bağlamda groovy << operatörü ne demektir?
- 2. Git, <<<<<<< HEAD dosyasına
- 3. Groovy: yöntem uygulanamaz (yakalama <?>)
- 4. Groovy:</p> İşte <pre><code>param = args[0] println(param) </code></pre> <p>bunu çalıştırmak nasıl (Windows 7):</p> <pre><code>groovy test.groovy a&b </code></pre> <p>beklediğim bu senaryo bir & b yazdırır
- 5. Python "dir" eşdeğeri Clojure
- 6. Ruby's #map ile Groovy eşdeğeri var mı?
- 7. En kısa özlü okunabilir sözdizimi <code>groovy</code> yılında
- 8. Kanal seç <- <- Kanal
- 9. EJS: <% = versus <% -
- 10. Java, bitshifts kullanırken, neden 1 << 32! = 1 << 31 << 1?
- 11. <: <İş nasıl?
- 12. İçindeki eleman sayısı <5 in <a1 <0</ a1><T>
- 13. strace -feopen eşdeğeri < command > mac os'da X
- 14. "<%:" ne yapıyor?</p> <pre><code><%: Model.FirstName %> </code></pre> <p>"<%:" Ne vermez: do
- 15. ruby bloğu ile başlar << - HTML
- 16. docker run -v <dir> vs Dockerfile's VOLUME <dir>
- 17. <section>, <nav> ve <article>
- 18. Mac'imde hangi Python sürümü var?</p> <pre><code>python --version </code></pre> <p>aldım:
- 19. Şu izle ifadem tutan bana gösteriyor Şu anda bir</p> <pre><code>Expression<Func<T,bool>> </code></pre> <p>bir</p> <pre><code>Expression<Func<T,object>> </code></pre> <p>dönüştürmek çalışıyorum
- 20. Objective-C'de özel yönergeler oluşturmak mümkün mü?</p> <ul> <li>@interface</li> <li>@implementation</li> <li>@end</li> <li>@protocol bence</li> <li>@property</li> <li>@synthesize</li> </ul> <p>:
- 21. C# Listesine erişim VBA eşdeğeri <T>
- 22. Rails'in .Where() nitelik ı <code>current_revision</code> ile <code>SectionRevision</code> ile ilişkilidir birçok <code>Section</code> modelleri içeren <code>Page</code> modele sahip
- 23. Postgres tarafından dizilerini bulmak ve ben iki tablo</p> <p><strong>tablo</strong><br> id <br> başlık <br> yıl</p> <hr> <p><strong>tablo b</strong><br> id <br> sahip diğer tablodan
- 24. <nedir? ve <? php
- 25. Nedir? ve << demek?
- 26. Bu garip koşullu operatör sözdizimi nedir?</p> <pre><code>bool bRes = (a < b) ? a=b, true : false; </code></pre> <p><code>a < b</code>, o zaman <code>a=b</code> infaz ve <code>bRes</code> doğrudur edilir:
- 27. ANT'de "**" ne anlama geliyor?</p> <pre><code><copy todir="/something"> <fileset dir="/source"> <exclude name="**/*.sql"/> </fileset> </copy> </code></pre> <p>adı özelliğinde <code>**</code> nedir:
- 28. Sözlük <> bir IEnumerable <> kaynağı ile doldurma</ a0><a1></ a1>
- 29. ek açıklama eşdeğeri <aop: scoped-proxy>
- 30. Django <input><label>
Terimi sağladığınız için teşekkür ederiz! – WilliamShatner