Functional Programming, Simplified: (Scala edition) by Alvin Alexander

Functional Programming, Simplified: (Scala edition) by Alvin Alexander

Author:Alvin Alexander [Alexander, Alvin]
Language: eng
Format: azw3, pdf
Publisher: Alvin Alexander
Published: 2017-10-17T04:00:00+00:00


2) A function that takes a by-name parameter

A second thing that can look like this FOO example:

val x = FOO { // more code here }

is a function that takes a by-name parameter.

In the Scala Cookbook I shared a timer function that can be used like this:

val (result, time) = timer { // some long-running block of code here ... Thread.sleep(1000) 42 }

When I run that code I get a result like this:

result: 42, time: 1004.819575

As that example shows, the timer function does three things:

Accepts a block of code



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.