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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:59:31+00:00 2026-05-31T09:59:31+00:00

This code works OK: val StringManifest = manifest[String] val IntManifest = manifest[Int] def check[T:

  • 0

This code works OK:

val StringManifest = manifest[String]
val IntManifest = manifest[Int]

def check[T: Manifest] = manifest[T] match {
    case StringManifest => "string"
    case IntManifest => "int"
    case _ => "something else"
}

But if we lowercase the first letter of the variables:

val stringManifest = manifest[String]
val intManifest = manifest[Int]

def check[T: Manifest] = manifest[T] match {
    case stringManifest => "string"
    case intManifest => "int"
    case _ => "something else"
}

we will get “unreachable code” error.

What are the reasons of this behavior?

  • 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-31T09:59:32+00:00Added an answer on May 31, 2026 at 9:59 am

    In scala’s pattern matching, lowercase is used for variables that should be bound by the matcher. Uppercase variables or backticks are used for existing variable that should be used by the matcher.

    Try this instead:

    def check[T: Manifest] = manifest[T] match {
      case `stringManifest` => "string"
      case `intManifest` => "int"
      case _ => "something else"
    }
    

    The reason you’re getting the “Unreachable code” error is that, in your code, stringManifest is a variable that will always bind to whatever manifest is. Since it will always bind, that case will always be used, and the intManifest and _ cases will never be used.

    Here’s a short demonstration showing the behavior

    val a = 1
    val A = 3
    List(1,2,3).foreach {
      case `a` => println("matched a")
      case A => println("matched A")
      case a => println("found " + a)
    }
    

    This yields:

    matched a
    found 2
    matched A
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code works (C# 3) double d; if(d == (double)(int)d) ...; Is there a
This code works correctly to make a web service call: int numberOfGuests = Convert.ToInt32(search.Guest);
This code works: class Test { public: Test(string name) : _name(name) {}; bool operator()()
This code works: $('[id$=lbl]').val() == 0 ? alert('Bla') : null; but this codes don't:
Can someone explain why this code works: $('#FonykerUsernameRegister').blur(function(){ if($(this).val().length > 2) { $.ajax({ url:
This code works fine: $result = $client->__call(optionalInfo, array( new SoapParam(..., client), new SoapParam(..., add_code))
This code works, but i dont understand why. With DeferredLoadingEnabld = false, I would
This code works in a windows forms application (it shows the preview) but not
This code works: monkey.h @interface monkey : NSObject { NSNumber *monkeyRanch; } @property (nonatomic,
This code works (when ControlType=dropDown then the background yellow ): <Window x:Class=TestCollapsed.Views.MainView xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml

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.