private-methods Questions

4

Solved

I want to call a private functions of class SomeClass from outside of this class: class SomeClass { private fun somePrivateFunction() { //... } private fun somePrivateFunctionWithParams(text: ...
Gaucherie asked 17/12, 2019 at 9:12

12

Solved

There are a group of private methods in my class, and I need to call one dynamically based on an input value. Both the invoking code and the target methods are in the same instance. The code looks ...
Demerit asked 25/9, 2008 at 19:26

5

I'm trying to define a private method for a class to test that such a method can't be called from outside the class. However, I'm coming across an error even when I'm using the syntax as indicated ...
Carabao asked 20/11, 2019 at 20:18

1

Solved

I wrote a simple code: const secure = new class { #privateProperty = 4; #privateMethod() { console.log( 'The property ' + this.#privateProperty + ' should not be accessible outside this class' )...

1

How can I test a private method that takes a generic type using privateMethodTester in scala? Let's say I have the following method: private def parseValueForJsonKeyWithReturnType[A: TypeTag]( n...
Sisterhood asked 26/6, 2018 at 4:40

2

Solved

Whenever I define a private method like this: class ParentClass { sayHi() { _initiateGreeting(); } _initiateGreeting() { print("I'm a parent class"); } } It is not possible to redefine it in...
Julie asked 6/1, 2014 at 20:57

7

Solved

Members of a class are by default private in c++. Hence, I wonder whether there is any possible use of creating a class that has all its members (variables and functions) set by default to privat...
Momently asked 11/9, 2014 at 10:27

34

Solved

To make a JavaScript class with a public method I'd do something like: function Restaurant() {} Restaurant.prototype.buy_food = function(){ // something here } Restaurant.prototype.use_restroom...
Freiburg asked 11/9, 2008 at 1:12

6

Solved

Am using JMockit 1.1 and all I want to do is invoke a private method and test the return value. However, I am having trouble understanding exactly how to do this from the JMockit De-Encapsulation e...
Besant asked 24/3, 2013 at 6:18

2

I was writing ES6 class with private properties/methods in vue project. And using eslint to lint the code. Below is the example class: class TestClass { constructor(value) { this.#privatePropert...
Seeder asked 13/1, 2020 at 8:54

3

The company I work for is coming near to completion of app for internal use only amongst employees. There are some things that from my research I am not clear on and would like to hear from people ...

8

Solved

When should i make a function private and why is it good idea?
Sybilla asked 22/12, 2010 at 3:31

10

Solved

I have a two part question Best-Practice I have an algorithm that performs some operation on a data structure using the public interface It is currently a module with numerous static methods, al...
Vina asked 25/11, 2008 at 21:1

6

Solved

I have confusion about using private methods in inheritance, for example: public class A { private void say(int number){ System.out.print("A:"+number); } } public class B extends A{ public v...
Borgia asked 19/10, 2013 at 2:57

5

If I'm writing a private method, does rails think that every method under the word private is going to be private? or is it supposed to be only private for the first method? private def signed_...
Violinist asked 12/5, 2013 at 17:43

6

C# compiler gave me the following error CS0191: A readonly field cannot be assigned to (except in a constructor or a variable initializer) Do I have to move the code (in my private function) into...
Hodgkin asked 27/7, 2011 at 17:12

6

Solved

I am working in C, and have some variables that I don't want to be global, but I do want to have get and set methods for them that can be accessed "Globaly" outside of the file. I am used to doing ...
Hairstreak asked 25/4, 2012 at 16:38

8

Solved

I am in the process of writing some unit tests. In particular I want to test some private methods. So far the I have come up with using. #define private public But I am not happy with this as i...
Diseur asked 9/9, 2010 at 12:51

3

Solved

Private interface methods are supported by Java 9. This support allows non-abstract methods of an interface to share code between them. Private methods can be static or instance. Can private meth...
Draco asked 14/9, 2017 at 12:8

11

Solved

We have a Student class in our business model. something struck me as strange, if we are manipulating one student from another student, the students private members are visible, why is this? class...
Florida asked 19/1, 2010 at 0:40

8

Solved

I am trying to do unit testing (using the Boost unit testing framework) on a C++ class called VariableImpl. Here are the details. class Variable { public: void UpdateStatistics (void) { // comput...
Sweeney asked 21/7, 2011 at 15:22

11

Solved

Consider this code: struct A { void foo() const { std::cout << "const" << std::endl; } private: void foo() { std::cout << "non - const" << std:...

7

Solved

I was examining the StringTokenizer.java class and there were a few questions that came to mind. I noticed that the public methods which are to be used by other classes invoked some private metho...

13

Solved

Is there a convention for naming the private method that I have called "_Add" here? I am not a fan of the leading underscore but it is what one of my teammates suggests. public Vector Add(Ve...
Sepulture asked 20/12, 2008 at 23:1

1

Solved

I have code as follows: class A private def p_method puts "I'm a private method from A" end end class B < A def some_method p_method end end b = B.new b.p_method # => Error: Private...
Actinotherapy asked 4/7, 2015 at 6:19

© 2022 - 2025 — McMap. All rights reserved.