isKindOf

View: New views
3 Messages — Rating Filter:   Alert me  

isKindOf

by thor-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi list

Why is it that when I run the latter line many times I sometimes get false and
sometimes true?

I'd think it should always be true, no?

a = List.new
a.isKindOf("SCWindow")




Re: isKindOf

by James Harkins-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Jul 16, 2008 at 5:20 PM, thor <th.list@...> wrote:
> Hi list
> Why is it that when I run the latter line many times I sometimes get false
> and
> sometimes true?
> I'd think it should always be true, no?
> a = List.new
> a.isKindOf("SCWindow")

Bizarre... actually I think it should throw an error in this case.
isKindOf expects a Class as the argument, not a string.

a.isKindOf(SCWindow) should always be false (if a is a List).

a.isKindOf('SCWindow') properly throws a "wrong type" error.

a.isKindOf("SCWindow") should likewise fail but it goes through and
returns garbage.

BTW, did you notice that this also returns false (most of the time)?

a = List.new;
a.isKindOf("List");

hjh


--
James Harkins /// dewdrop world
jamshark70@...
http://www.dewdrop-world.net

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal." -- Whitman

_______________________________________________
sc-users mailing list

info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: isKindOf

by thor-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Ha!

Sorry, I pasted the upper line after testing with List as well.
Obviously I didn't want to check if a List was a SCWindow.

But that made it even more bizarre as you say : )
This sometimes returns true:
a = List.new
a.isKindOf("Top 10 Best Seller List")

So basically my mistake was to put in a string.

thanks James, problem solved in my patch, but something smelly is going
on in the primitive perhaps?


On 16 Jul 2008, at 22:26, James Harkins wrote:

On Wed, Jul 16, 2008 at 5:20 PM, thor <th.list@...> wrote:
Hi list
Why is it that when I run the latter line many times I sometimes get false
and
sometimes true?
I'd think it should always be true, no?
a = List.new
a.isKindOf("SCWindow")

Bizarre... actually I think it should throw an error in this case.
isKindOf expects a Class as the argument, not a string.

a.isKindOf(SCWindow) should always be false (if a is a List).

a.isKindOf('SCWindow') properly throws a "wrong type" error.

a.isKindOf("SCWindow") should likewise fail but it goes through and
returns garbage.

BTW, did you notice that this also returns false (most of the time)?

a = List.new;
a.isKindOf("List");

hjh


-- 
James Harkins /// dewdrop world

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal." -- Whitman

_______________________________________________
sc-users mailing list


LightInTheBox - Buy quality products at wholesale price