haxe.ds.ArraySort.sort and the using keyword

72 views
Skip to first unread message

Rezmason

unread,
Mar 27, 2013, 5:33:00 PM3/27/13
to haxe...@googlegroups.com
Hey guys,

As of this morning I can attest to the relative ease of migrating a Haxe project to Haxe 3. And by migrate, I mean compile, not benefit from– I'm still working on that.

For instance, I've discovered the ArraySort class, which I think is really useful. However, I'm not sure whether ArraySort.sort<T>(a:Array<T>, cmp:T -> T -> Int) works with the using keyword. After all, Arrays already have a method called sort; is the "using haxe.ds.ArraySort;" statement sufficient for indicating to the compiler that "myArray.sort(sortFunc) should use ArraySort.sort?

Jason O'Neil

unread,
Mar 27, 2013, 5:59:37 PM3/27/13
to haxe...@googlegroups.com
No, "using" will only take effect if there is not a member method on the object you are calling - so in this case ArraySort.sort() will not override myArray.sort().

You could work around it by having another name

class MyArraySort
{
  static inline public function arraySort(a, cmp) return ArraySort.sort(a, cmp);
}

using MyArraySort;

myArray.arraySort(....);

Not that it's ideal, but yeah.


--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages