From: gabriele renzi Date: 2005-07-20T16:30:56+09:00 Subject: Re: Ruby/Rails as a starter language? Hal Fulton ha scritto: > Adam P. Jenkins wrote: > >> >> Yes you are being pedantic. In Java classes certainly are objects, >> it's just that the syntax for getting at the class object is a little >> different from Ruby: >> >> In Java: >> >> class Foo {} // define a class >> Class clazz = Foo.class; // assign class to a variable > > > If Foo is a class, what is Foo.class? the way you rreference the Foo class. think of it as a literal. I should be also noticed that this way you can reference even the types of non-classes (you can do MyInterface.class int.class, void.class etc) >> Foo foo = new Foo(); // create an instance >> clazz = foo.getClass(); // get instance's class object > > > Can you say this? > > bar = new clazz(); > > And does getClass return you Foo or Foo.class? you can do Foo foo = clazz.getInstance() ;