Skip to content
Martin Prout edited this page Aug 11, 2013 · 29 revisions

Some people think java reflection is cool (they are mistaken, it is not is a pain), where possible avoid using it at all costs, unfortunately some of the processing guys seem to think it is cool, so they have contaminated the processing api with it. Fortunately there are often ways to avoid it (and sometimes come up with something that is more appropriate for use in a ruby environment). One such example is the thread convenience method of processing, that relies on reflection to allow you to pass a function to a thread.

thread("someFunction");
void someFunction(){
  do stuff..
}

In ruby-processing we have overridden the thread convenience method to be much more ruby like (in keeping with ruby Thread, whilst actually using java thread under hood) to take a block.

thread do
  some stuff..
end

Actually we don't really need this convenience function in ruby-processing I've just overridden it to prevent any confusion it is just as easy to use the existing Thread syntax...

Thread.new do
  some stuff..
end
Clone this wiki locally