Scala:
val y = Math.max(5,x)

Java:
final int y = Math.max(5,x)


Pretty much the same, except that Java is a tiny bit more verbose, and the
Java code would need extra maintenance if you wanted to change x to be e.g.
a double.


On 25 August 2010 11:05, Ben Schulz <[email protected]> wrote:

> Sure, how about this:
>
> var y = -1; // why the initialization?? so complicated
> if(x > 5)
>  y = x;
> else
>  y = 5;
>
> versus
>
> final int y; // ahh, definite assignment, so simple (*)
> if (x > 5) {
>  y = x;
> } else {
>  y = 5;
> }
>
> Then there's the security aspect.
>
> private[yourscopehere] def getRootAccess() = {
>  // this better not be public
> }
>
> I'm sure there's more, but I'm also sure the rules are about to shift
> in Scala's favor. Again.
>
> With kind regards
> Ben
>
> (*) Generally I would list definite assignment as making Java more
> complicated, but sine the code is more concise and closer to the
> intent....
>
> On 25 Aug., 08:55, Kevin Wright <[email protected]> wrote:
> > http://michid.wordpress.com/2010/08/24/so-scala-is-too-complex/
> >
> > <http://michid.wordpress.com/2010/08/24/so-scala-is-too-complex/>I'm
> > curious, does anyone have an example of the same problem being solved in
> > both Java and Scala, with Java offering the simplest solution?
> >
> > --
> > Kevin Wright
> >
> > mail/google talk: [email protected]
> > wave: [email protected]
> > skype: kev.lee.wright
> > twitter: @thecoda
>
> --
> You received this message because you are subscribed to the Google Groups
> "The Java Posse" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<javaposse%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/javaposse?hl=en.
>
>


-- 
Kevin Wright

mail/google talk: [email protected]
wave: [email protected]
skype: kev.lee.wright
twitter: @thecoda

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to