No, I'm talking about something different. I don't know Javascript well enough to toss off something, but the equivalent in Ruby looks like this:
class MyBadassSword < GameObject
is_immune_to_poison
is_fire_resistant
reflects_magic
end
When is_immune_to_poison is called, it reopens MyBadassSword and attaches more code to it. This is not a syntax feature of Ruby so much as using .include to append more code modules or rewrite definitions to it. The Java JVM supports this, but you have to jump through a lot of hoops to do that with Java itself.
The POISON_IMMUNITY | FIRE_RESISTENCE | REFLECTS_MAGIC is exactly what I don't want to mess with. I'm not instantiating PoisonImmunity() class. I'm not using bit fields like POISON_IMMUNITY. (I specifically said in my previous post I was not talking about bit fields). I'm not talking about pulling strings from a configuration file.
I find that a touch inscrutable, but to make an object have various behaviors certainly doesn't require subclassing.
or, in one line: or, super-fast mode: or, pulling from some configuration file: ...maybe you're doing something I don't grasp, but it seems like another case of pretending that java has a disability that it doesn't.