Oops, my bad.

Ilya Furman





On Sat, Nov 7, 2009 at 16:44, T.J. Crowder <t...@crowdersoftware.com> wrote:
>
> Hi,
>
> The initializer is called "initialize", not "initialization" (see the
> docs[1]).  Your code throwing the exception isn't being called, hence
> the exception not being thrown.  If you use the correct name, the
> exception is thrown and correctly propagates out to the code creating
> the object.
>
> [1] http://api.prototypejs.org/language/class.html
>
> HTH,
> --
> T.J. Crowder
> Independent Software Consultant
> tj / crowder software / com
> www.crowdersoftware.com
>
> On Nov 6, 4:23 pm, Ilya Furman <smashl...@gmail.com> wrote:
>> Hello!
>>
>> I'm wondering, why class instance is being created while
>> initialization method throws an error?
>>
>> var C = Class.create({
>>   initialization : function() {
>>     throw new Error('Hey, you can\'t have any instances of this
>> class!')
>>   },
>>   foo : 'foofoo' ,
>>   bar : function() {
>>     alert(this.foo)
>>   }
>>
>> });
>>
>> var c = new C();
>> c.bar();
>>
>> Demo linkhttp://jsbin.com/inoqi
>>
>> Variable c should be 'undefined' I suppose, without any methods and
>> properties.
>> Seems like there is actually no way to stop instance from being
>> created.
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to