Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7573771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:15:58+00:00 2026-05-30T16:15:58+00:00

What exactly that declaration of method parameter means: def myFunc(param: => Int) = param

  • 0

What exactly that declaration of method parameter means:

def myFunc(param: => Int) = param

What is meaning of => in upper definition?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T16:16:00+00:00Added an answer on May 30, 2026 at 4:16 pm

    This is so-called pass-by-name. It means you are passing a function that should return Int but is mostly used to implement lazy evaluation of parameters. It is somewhat similar to:

    def myFunc(param: () => Int) = param
    

    Here is an example. Consider an answer function returning some Int value:

    def answer = { println("answer"); 40 }
    

    And two functions, one taking Int and one taking Int by-name:

    def eagerEval(x: Int)   = { println("eager"); x; }
    def lazyEval(x: => Int) = { println("lazy");  x; }
    

    Now execute both of them using answer:

    eagerEval(answer + 2)
    > answer
    > eager
    
    lazyEval(answer + 2)
    > lazy
    > answer
    

    The first case is obvious: before calling eagerEval() answer is evaluated and prints "answer" string. The second case is much more interesting. We are actually passing a function to lazyEval(). The lazyEval first prints "lazy" and evaluates the x parameter (actually, calls x function passed as a parameter).

    See also

    • Scala Returning a void function with 0 parameters, ugly syntax?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a C function declaration, I have seen this parameter definition: void *userData so,
Given the property declaration below, does method (A) work in exactly the same way
Exactly that: Does a strings length equal the byte size? Does it matter on
My question is exactly that but in context I want to examine the selection
So why exactly is it that it's always recommended to use const as often
Doug McCune had created something that was exactly what I needed ( http://dougmccune.com/blog/2007/05/10/analyze-your-actionscript-code-with-this-apollo-app/ )
I have two webservices that have exactly the same methods and signatures but point
In the code there exists exactly one type that implements IResourceConverter. That's what the
I want to create a regexp in Emacs that matches exactly 3 digits. For
Strawberry Perl is Open Source Perl for Windows that is exactly the same as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.