aspose file tools*
The moose likes Scala and the fly likes Incrementing the for loop (loop variable) in scala by power of 5 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Languages » Scala
Bookmark "Incrementing the for loop (loop variable) in scala by power of 5" Watch "Incrementing the for loop (loop variable) in scala by power of 5" New topic
Author

Incrementing the for loop (loop variable) in scala by power of 5

Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

I have this particular requirement where the increment in the loop variable is to be done by multiplying it with 5 after each iteration. In Java we could implement it this way

In scala I was trying the following code-

But its printing the following output:
1 1
6 2
11 3
16 4
21 5
26 6
31 7
36 8
....
....

Its incrementing by 5 always. So how do I got about actually multiplying the increment by 5 instead of adding it.


Mohamed Sanaulla | My Blog
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

Posted on Stackoverflow as well: http://stackoverflow.com/questions/4194075/incrementing-the-for-loop-loop-variable-in-scala-by-power-of-5
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

The query has been answered on Stackoverflow. Link provided in the previous post.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Incrementing the for loop (loop variable) in scala by power of 5