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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:02:18+00:00 2026-06-04T01:02:18+00:00

According to the Play 2.0 documentation , pattern matching can be done in a

  • 0

According to the Play 2.0 documentation, pattern matching can be done in a template like so:

@connected match {

  case models.Admin(name) => {
    <span class="admin">Connected as admin (@name)</span>
  }

  case models.User(name) => {
    <span>Connected as @name</span>
  }   
}

The text between the brackets after the case expressions is treated as output (e.g. HTML), and this is quite convenient.

However, when attempting to use a match expression that is not a simple variable, such as object.member, like this:

@album.year match {
   case Some(y: Int) => { @y }
   case None => { <b>nope</b> }
}

it results in a compilation error:
"')' expected but 'case' found."

Using defining to bind the expression to a simple variable, like this:

@defining(album.year) { foo =>
  @foo match {
        case Some(y: Int) => { @y }
        case None => { <b>nope</b> }
      }
  }

works, but it seems a bit cumbersome.

Is there a proper way to use this pattern matching feature on expressions that involve an object and a member (e.g. album.year)?

  • 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-06-04T01:02:19+00:00Added an answer on June 4, 2026 at 1:02 am

    Not currently possible (in version 2.0.1), as it is a confirmed bug:

    https://play.lighthouseapp.com/projects/82401/tickets/46-support-more-complex-match-statement

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

Sidebar

Related Questions

According to the NetStream API , Flash can play LOCAL RAW video by calling
According to the Play documentation , it is possible to pack a Play app
According to http://lipas.uwasa.fi/~ts/info/proctips.html#orrules , you can make basic or rules in .procmailrc with something
According to the class ElementType in the API, you can annotate local variables and
Is there a way to play UILocalNotification sound loudly ignoring the volume settings? Like
i want to play sound according to text of the label.is this possible to
In android, I am trying to implement an application that can play videos. In
AudioServicesPlaySystemSound() is playing my sounds using ringer volume. I want them to play according
I am playing a video by default in full screen according to this: Play
I have an ASX stream that I would like to play on my Windows

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.