mid-stream varible bindings

View: New views
2 Messages — Rating Filter:   Alert me  

mid-stream varible bindings

by Kubitz, Jörg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

I tried a mid-stream varible binding.

This does not work:

 

  for (i <- 1 to 10

    f=i*2

    if i*2==3

  ) println(f)

 

 

Why?


Re: mid-stream varible bindings

by Ricky Clarkson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Another day I'd say "I don't know.  Have you considered telling us how
it doesn't work?"

Today though:

for (i <- 1 to 10;
  f = i * 2;
  if i * 2 == 3) println(f) // works

for { i <- 1 to 10
  f = i * 2
  if i * 2 == 3 } println(f) // works

2009/11/6 Kubitz, Jörg <jkubitz@...>:

> I tried a mid-stream varible binding.
>
> This does not work:
>
>
>
>   for (i <- 1 to 10
>
>     f=i*2
>
>     if i*2==3
>
>   ) println(f)
>
>
>
>
>
> Why?



--
Ricky Clarkson
Java and Scala Programmer, AD Holdings
+44 1565 770804
Skype: ricky_clarkson
Google Talk: ricky.clarkson@...
Google Wave: ricky.clarkson@...