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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:04:42+00:00 2026-06-13T20:04:42+00:00

This is an excerpt from a larger body of code with non pertinent code

  • 0

This is an excerpt from a larger body of code with non pertinent code removed for brevity. I’ve tested the code below on it’s own (as a single class in a new project) and verified that the same exact issue persists. So I know that the problem is specific to the code contained here.

object HumanGUI extends SimpleGUIApplication with Logs {

  PropertyConfigurator.configure("log4j.properties")

  def top = new MainFrame {
    title = "BJ GUI"

  val PlayPanel = new BoxPanel(Orientation.Vertical) {
    val hitButton = new Button("Hit")
    val stayButton = new Button("Stay")
    val doubleButton = new Button("Double")
    val quitButton = new Button("Quit")

    contents += hitButton
    contents += stayButton
    contents += doubleButton
    contents += quitButton

    listenTo(hitButton, stayButton, doubleButton, quitButton)
    reactions += {
      case ButtonClicked(hitButton) =>
        debug("Clicked Hit!")
      case ButtonClicked(stayButton) =>
        debug("Clicked Stay!")
      case ButtonClicked(doubleButton) =>
        debug("Clicked Double!")
      case ButtonClicked(quitButton) =>
        debug("Clicked Quit!")
    }

    contents = new BoxPanel(Orientation.Vertical) {
      contents += playPanel
    }
  }  

Specifically, the compiler is telling me that the last 3 cases in this block are unreachable:

    listenTo(hitButton, stayButton, doubleButton, quitButton)
    reactions += {
      case ButtonClicked(hitButton) =>
        debug("Clicked Hit!")
      case ButtonClicked(stayButton) =>
        debug("Clicked Stay!")
      case ButtonClicked(doubleButton) =>
        debug("Clicked Double!")
      case ButtonClicked(quitButton) =>
        debug("Clicked Quit!")
    }

Why would this be the case?

  • 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-13T20:04:44+00:00Added an answer on June 13, 2026 at 8:04 pm

    When pattern matching all lower case variables will be bound to what is matched in that case, if you want to match against a variable outside of a pattern match you have to use ` (back tick):

    listenTo(hitButton, stayButton, doubleButton, quitButton)
        reactions += {
          case ButtonClicked(`hitButton`) =>
            debug("Clicked Hit!")
          case ButtonClicked(`stayButton`) =>
            debug("Clicked Stay!")
          case ButtonClicked(`doubleButton`) =>
            debug("Clicked Double!")
          case ButtonClicked(`quitButton`) =>
            debug("Clicked Quit!")
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following HTML (excerpt from larger code-base) <div class=diary-event ui-corner-all title=[title]> <span
Greetings! I must be seeing things. Look at this excerpt from the iPhone OS
This is an excerpt of some c++ code, that i'll have to explain in
I have this HTML structure (excerpt): <td> <select id=test1 class=pub_chooser> <option value=99>All Publications</option> <option
I read this question in stackoverflow. The excerpt answer provided by bbum is below:
i been working in the login code .. it works fine except this message
This code works for me except it only checks for a duplicate once, and
This code works perfectly except when you click on a link, The page is
I was creating a very simple class as part of a much larger project.
I'm training code problems, and on this one I am having problems to solve

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.