electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
Live streaming at radio.electro-music.com

  host / artist show at your time

poster

Please visit the chat
 Forum index » DIY Hardware and Software » ChucK programming language
Instanceof in ChucK?
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [3 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
WillHS



Joined: Oct 27, 2014
Posts: 4
Location: New Zealand

PostPosted: Thu Oct 30, 2014 5:15 am    Post subject: Instanceof in ChucK? Reply with quote  Mark this post and the followings unread

In Java, the instanceof keyword can be used to check whether an object is an instance of class x or a sub-class of x.

Is there a way to check if an object is an instance of a particular class or sub-class of a particular class?
Back to top
View user's profile Send private message
kingcrabmeat



Joined: Sep 04, 2014
Posts: 4
Location: US and A

PostPosted: Thu Oct 30, 2014 1:34 pm    Post subject: Reply with quote  Mark this post and the followings unread

I doubt that there is such a feature. I would suggest including an identifier variable like so:
Code:
class A {
    0 => int id;
}

class B extends A {
    1 => id;
}

A a;
B b;

if( a.id == b.id )
    <<< "same" >>>;
else
    <<< "different" >>>;

You probably considered this already. Anyway, you're right to ask because the documentation on the ChucK website isn't very current. The ChucK mailing list might be a good place to submit questions about bugs and features if not on this forum.
Back to top
View user's profile Send private message
WillHS



Joined: Oct 27, 2014
Posts: 4
Location: New Zealand

PostPosted: Thu Oct 30, 2014 3:27 pm    Post subject: Reply with quote  Mark this post and the followings unread

Quote:
The ChucK mailing list might be a good place to submit questions about bugs and features if not on this forum.

OK, thanks for the suggestion. Will try the mailing list.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [3 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » ChucK programming language
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
e-m mkii

Please support our site. If you click through and buy from
our affiliate partners, we earn a small commission.


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use