> From: Niclas Hedhman [mailto:[EMAIL PROTECTED] 
> 
> On Wednesday 28 January 2004 11:38, Jonathan Hawkes wrote:
> > >     MyComponent comp = sm.lookup (MyComponent.class, 
> "MyComponent");
> >
> > I like that.
> 
> Didn't Leo forgot the Template??
> 
> MyComponent comp = sm.<MyComponent>lookup (MyComponent.class, 
> "MyComponent");
> 
> Or would it really be possible to skip?

The template argument is inferred from the MyComponent.class 
parameter.

The reason you needed the explicit <MyComponent> in the other
example is because it couldn't be inferred from any of the
arguments.

Note: The compiler must know the type of the argument to
perform inference. Thus this does ***not*** work:

    Class c = MyComponent.class;
    MyComponent comp = sm.lookup (c, "MyComponent");

This, however, does:

    Class<MyComponent> c = MyComponent.class;
    MyComponent comp = sm.lookup (c, "MyComponent");

/LS


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to