At 4/10/14 11:14 AM, Sam wrote:
switch(value)
{
case c1, c2:
trace("Matched");
}
Awesome, thanks! Didn't know I could comma delimit.
I'd much a C-like cast
(Car) vehicle;
Right, just some kind of type indicator
howver Haxe has a nice Type.getType(), util, if its not as costly as reflections, then there's a lot of parts in my serializer that could benefit from:
switch(Type.getClass(thing)){
case Car:...
case whatever:..
rather than a series of if(x is y)
Do they have to have the underscore? I'm really not sure, I tend to just write my own getter and setter which aren't actual proper ones (I'm such a bad programmer).
You mean like this:
public function getX():Number { return _x; }
If it's any consolation, property-like getters are overused by bad programmers, sometime you need that parenthesis to say "Hey there's more going on here, don't treat me like a variable"
At 4/10/14 11:18 AM, MSGhero wrote:
Array comprehension is amazing, plus the great and powerful Lambda for other goodies.
var a = [for (i in 0...100) if (i % 2 == 0) i];
Lib.trace(a); // 0,2,4,6,...
yeah, that's what I was thinking of. But this raises a previous suspicion I was worried about. In the "Loops" section of PSVills link, the as3 section has type declarations, where Haxe does not. do I just not have to type loop incrementers?
You can use traditional for loops as well.
good to know.
From Nic on underscores:
That's why I'm still in favor of using get_xxx/set_xxx, because we need
to create actual real methods that will be callable at runtime and
visible through reflection. Hiding them by using abstract concepts will
just trigger more misunderstanding by the haXe user."
I guess that makes sense, but when would I use reflection on a getter/setter? I guess you can use it like a pointer or something. either way using C# style get/set and having a Reflect.findGetter(thing, 'x'), would be preferable.
At 4/10/14 10:23 AM, Sam wrote:
One thing that I think is a bad design choice is the omission of the protected keyword, and the change of the private keyword to be what protected means in AS3.
You could make a public var with set access set to "never." It would still be gettable from within subclasses, but setting would throw an error.
It's just lame, one of the main benefits of encapsulation is not having every private variable pop up when I type 'this.' in a derived class.
At 4/10/14 11:42 AM, MSGhero wrote:
for (i in [for (j in 0...100) if (j % 2 == 0) j]) {
do stuff to evens
}
why not just:
for (i in 0...100) if (i % 2 == 0) {
do stuff to evens
}
also, it would be nice if that slimmed down for loop had a way to specify an interval other than one, I.E.: -1 or 2
something like :
for(i in 0...100; i+=2)