java - What does this block of Scala code mean -


hi relatively new scala, try play 2 framework , stuck following code (used template)

<article  class="tasks">         @todotasks.groupby(_.project).map {             case (project, tasks) => {                 <div class="folder" data-folder-id="@project.id">                     <header>                         <h3>@project.name</h3>                     </header>                     <ul class="list">                         @tasks.map { task =>                             <li data-task-id="@task.id">                                 <h4>@task.title</h4>                             </li>                         }                     </ul>                 </div>             }         }     </article> 

what line mean?

@todotasks.groupby(_.project).map { 

and how use scala *.map in context of play 2 framework.

i'd appreciate if explain in exact detail relatively new scala (coming java developer)

groupby() applies given lambda expression (_.project, extracts project task) each element of collection, , groups elements results of expression.

so, converts list of tasks list of tuples (project, tasksofthatproject).

now, map() applies lambda expression each element of collection (i.e. each of these tuples).

lambda expression given map() renders tuple project name , list of tasks.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -