8

I'm trying to port some Java code into Scala:

while ((j=f('blah'))>=0) ...

ERROR:"value >= is not a member of Unit"

Is this not possible?

1
  • If you really need that, you're doin it rong... Commented Mar 4, 2013 at 9:36

1 Answer 1

23

Assignments return () (unit) in Scala. But that's okay because you can put a code block anywhere. You need this instead:

while ({ j=f("blah"); j } >= 0) ...
Sign up to request clarification or add additional context in comments.

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.