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 4575608
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:05:17+00:00 2026-05-21T20:05:17+00:00

in scala play framework I seen this code: abstract class AnalyserInfo case class ColumnC(typeName:String,fieldName:String)

  • 0

in scala play framework I seen this code:

abstract class AnalyserInfo
case class ColumnC(typeName:String,fieldName:String) extends AnalyserInfo
case class TableC(typeName:String) extends AnalyserInfo

    val asIs :PartialFunction[AnalyserInfo,String] = {
      case ColumnC(_,f) => f;
      case TableC(typeName) => typeName
    }

What is the difference with:

val asIs: (AnaliserInfo)=>String = (info) => info match {
  case ColumnC(_,f) => f;
  case TableC(typeName) => typeName
}

There is a preferred style? and why in the first case the match keyword can be omitted?

Thank you for the support.

  • 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-21T20:05:17+00:00Added an answer on May 21, 2026 at 8:05 pm

    Double => Double is just a shorthand for Function[Double, Double]. PartialFunction inherits from Function but adds a few methods. Most importantly, it adds the method isDefinedAt which allows you to query if the function is defined for some parameter.

    The cases without a match are a special syntax to define partial functions, which generates an isDefinedAt that returns true for all matching cases.

    Say we have a function that returns 1/x, but only for positive values of x, we could it define as:

    scala> val f: (Double => Double) = { case x if x > 0 => 1/x }             
    f: (Double) => Double = <function1>
    

    or as:

    scala> val g: PartialFunction[Double, Double] = { case x if x > 0 => 1/x }
    g: PartialFunction[Double,Double] = <function1>
    

    The second version has the benefit that we could check if the function is applicable to some parameter:

    scala> g.isDefinedAt(-3)
    res0: Boolean = false
    

    This feature is for example used in Scala to implement the actor library where an Actor might only consume certain types of messages.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running this scala code on a 32-bit quad-core Core2 system: def job(i:Int,s:Int):Long =
I'm trying to get started with the play web framework and its scala support,
When running javap -v on the compiled class resulting from this bit of Scala
Using Scala's command line REPL: def foo(x: Int): Unit = {} def foo(x: String):
In Scala, is it possible to get the string representation of a type at
While playing around with regexps in Scala I wrote something like this: scala> val
Suppose one wants to build a novel generic class, Novel[A] . This class will
I play a movie using the following code NSString *path = [[NSBundle mainBundle] pathForResource:@cobra
I would like to play with scala.ref.WeakReference . However, before trying to implement the
Any one been able to get a Scala and AspectJ (AJDT) to play nicely

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.