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

  • Home
  • SEARCH
  • 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 9174141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:42:23+00:00 2026-06-17T16:42:23+00:00

There is a class (specifically TypedPipe[T] in com.twitter.scalding ) that has only a private

  • 0

There is a class (specifically TypedPipe[T] in com.twitter.scalding) that has only a private constructor, and I wish to add some methods to it. It looks something like this

class TypedPipe[+T] private ( a : Int) { 

}

This is usually done by defining an implicit conversion method. However, I need access to a to define the method I want to. Is this simply impossible in Scala?

  • 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-17T16:42:24+00:00Added an answer on June 17, 2026 at 4:42 pm

    If I correctly interpreted your question, the answer is yes, this is simply impossible in Scala.
    This has nothing do to with the private constructor. If it were public, you would have exactly the same problem.

    class TypedPipe[+T] private ( a : Int) { 
    
    }
    

    The point here is that there is no val or var before a . a is not a property of TypedType, but only an argument to its constructor, i.e. no property is created to hold the value of a inside the object

    This is equivalent to the Java code:

    public class MyClass{
        private final String value;
        public MyClass(int a){
            System.out.println("I was initialized with " + a);
            this.value="b";
        }
    }
    

    and you can actually check it out easily with the REPL. If you want a to be accessible outside the constructor, it must either be a var or a val

    class TypedPipe[+T] private ( a : Int) {
      println(a)
    }
    
    class TypedPipe1[+T] private (val a : Int) {
      println(a)
    }
    

    I am a big fan of the javap disassembler in the REPL:

    scala> :javap -p TypedPipe
    
    scala> Compiled from "TypedType.scala"
    public class TypedPipe extends java.lang.Object implements scala.ScalaObject{
        private TypedPipe(int);
    }
    
    
    scala> :javap -p TypedPipe1
    
    scala> Compiled from "TypedType.scala"
    public class TypedPipe1 extends java.lang.Object implements scala.ScalaObject{
        private final int a;
        public int a();
        private TypedPipe1(int);
    }
    

    As you can see, in the first version there is no member property to hold the value of a, and no getter

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

Sidebar

Related Questions

There is class KeyboardView in Android that uses internally class Canvas , and specifically
Is there a class that overwrites the .MainMenu_MenuItem class for the Main Menu? I
Is there a class in the ASP.NET MVC framework that represents a controller name
Is there a class in the .NET BCL that can store a block of
Simple question: Is there a class or interface that encapulates the getting of a
Hello is there a class that does a pretty conversion?
Is there a method to retrieve the file name of a class? Specifically I
Are there any articles that describe how the DependencyObject class in WPF works under
Is there any diff tool specifically for Java that doesn't just highlight differences in
Is there a certain JSFL class that can be used to access the Clipboard's

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.