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

The Archive Base Latest Questions

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

I accidentally noticed the following: scala> class g[T](val x:T) defined class g scala> val

  • 0

I accidentally noticed the following:

scala> class g[T](val x:T)   
defined class g

scala> val obj=new g[Int]('A')
obj: g[Int] = g@1082d45

scala> obj.x
res6: Int = 65

What is happening here? A typecast?

  • 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-13T01:55:05+00:00Added an answer on June 13, 2026 at 1:55 am

    It’s upconversion of primitives. Primitive values will convert themselves to the next numerically-larger type if it seems like that is needed. So val s: Short = (0: Byte) works. Nothing converts to Char, but Char will become an Int, Long, Float, or Double if it needs to to be the right argument type.

    The reason this is done is mostly because it’s how Java does it, but partly because getting an error off of val d: Double = 0 is really annoying since 0 of course fits into a Double with no problems whatsoever, and there’s no ambiguity about the type either.

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

Sidebar

Related Questions

I noticed this accidentally when playing around in vimtutor. What's the difference between append
I noticed this accidentally one day, and now decided to test it extensively. So,
Kind of a strange question, but here is my scenario: I have accidentally added
I accidentally created following check, that works fine, but I'm curious why :) First
accidentally at work I wrote the following line of code: string x = (object)
I was trying to make moving bitmap with accelerometer smoother and accidentally noticed that
I have a SQLite database with my Android application. I have noticed I accidentally
I noticed I don't get any compiler errors when I accidentally forget to return
var Obj = function(){}; var X = new Obj(); will X = null properly
while working on a project I accidentally noticed that the same method with only

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.