- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
1::2::Nil sort >
I remember in C++, a pointer to a method could be passed around as a function
with 2 arguments, simply because methods are actually functions taking an
implicit first argument (maybe my memory doesn't serve me well anymore).
The question is: is there (or could there be) a syntax to get a method as a
function of 2 arguments? so I could simply write this:
1::2::NIl sort Int.>
or, if the compiler gets even smarter, the even more interesting:
1::2::NIl sort >
Right now I have to do this
scala> def > (i:Int,j:Int) = i > j
$greater: (i: Int,j: Int)Boolean
Worth considering?
-----
Razvan Cojocaru,
Work: http://www.sigma-systems.com
Playground: http://wiki.homecloud.ca
Latest cool toy: http://scripster.codewitter.com
Follow me: http://feeds.razie.com/RazvanTech RSS Feed ,
http://twitter.com/razie Twitter , http://github.com/razie GitHub .










Re: 1::2::Nil sort >
?
Plain '>' can't work in Scala. What would the following do?def > : (Int,Int)=>Int = ...1::2::Nil sort >
On Thu, Apr 29, 2010 at 9:39 AM, Razvan Cojocaru <razie [at] razie [dot] com> wrote:
Re: 1::2::Nil sort >
You can already write:
(1::2::Nil).sort(_>_)
The underscores define where arguments go in the expression.
-Arthur (sent from phone)
Re: 1::2::Nil sort >
On Thu, Apr 29, 2010 at 06:39:10AM -0700, Razvan Cojocaru wrote:
> The question is: is there (or could there be) a syntax to get a method
> as a function of 2 arguments? so I could simply write this:
>
> 1::2::NIl sort Int.>
scala> 1::2::Nil sort (_ > _)
warning: there were deprecation warnings; re-run with -deprecation for details
res0: List[Int] = List(2, 1)
Re: 1::2::Nil sort >
good point - this syntax is simple enough. i was hoping to avoid the ()
part...but it wouldn't be shorter.
-----
Razvan Cojocaru,
Work: http://www.sigma-systems.com
Playground: http://wiki.homecloud.ca
Latest cool toy: http://scripster.codewitter.com
Follow me: http://feeds.razie.com/RazvanTech RSS Feed ,
http://twitter.com/razie Twitter , http://github.com/razie GitHub .