Questions tagged [private-methods]
285 questions
1
vote
2 answers
undefined class/module YAML::PrivateType
I have uploaded a new version of gem to the server, successfully. If i
install the gem from local, its successfully installed.
But I'm getting following error while installing the same gem from
remote server.
ERROR: While executing gem ...…

Priya
- 11
- 1
1
vote
0 answers
verifyPrivate method of PowerMockito calls tested method
I want to check if a private method is called inside my tested method. Since the method is private I use this :
PowerMockito.verifyPrivate(societeHome, times(1)).invoke("createFournisseurSocieteBinding", Mockito.any());
This test ALWAYS passes, I…

Sly
- 51
- 5
1
vote
2 answers
Why only call a private function in a public function?
I was wandering in the source code of the fabulous python-chess library when I saw the following code:
def _reset_board(self):
# code...
def reset_board(self):
self._reset_board()
The reset_board() function only does one thing, call its…

Null User
- 338
- 1
- 4
- 17
1
vote
1 answer
Will compilers optimize out unused private methods?
Does javac leave out private methods if they are inlined?
For example
public class Test {
public static void main(String[] args){
System.out.println(sayHello());
}
private static String sayHello(){
return "Hello World";
}
}
But what…

vikarjramun
- 1,042
- 12
- 30
1
vote
0 answers
Angular Material 2 : MdSelect dropdown overlay positionning
I have implemented the select component of Material Angular and the dropdown overlay is placed over the select field like that :
I would like to place the dropdown at the bottom of the select field.
In fact, the placement of the overlay is…

rachelle
- 91
- 1
- 6
1
vote
2 answers
Call Private methods outside class definition
I'm trying to use a Gem that provides me with a DSL i need to apply on some of my classes. But using it directly makes my class definitions not as clean as i want them to be, so i want to move the code that uses the DSL somewhere else, which bring…

rccursach
- 305
- 3
- 14
1
vote
1 answer
can I call a private function from within the same object javascript
ETA: I don't believe this question is a duplicate to the one linked. I know how to return a private variable (as shown below in the code), this question was about how to call a private function within the same object.
I'm having trouble finding…

Angie
- 25
- 5
1
vote
2 answers
How to do the Assert phase of a private method whose return type is Void?
I have a class with a private method
public class MyClass
{
private void SomeMethod(PrimaryAllocationDP packet)
{
........................
some code
........................
packet.AllocatedAgency =…

priyanka.sarkar
- 25,766
- 43
- 127
- 173
1
vote
1 answer
Unit Testing private functions that require keychain authentication in swift
Thanks in advance for any advice!
I'm setting up some unit tests in swift for iOS development. The method requires a call to the keychain to create an authToken to successfully run the function. I'm not sure how to approach creating a unit test for…

Sean Weiss
- 63
- 1
- 5
1
vote
1 answer
Class instance variable does not retain changes when method is called
I created a class in MATLAB:
classdef Compiler
%UNTITLED2 Summary of this class goes here
% Detailed explanation goes here
properties(Access = public)
in='' %a line of string of MATLAB code
out={} %several lines of string(cell…

Michelle Shieh
- 145
- 1
- 1
- 8
1
vote
1 answer
Powermock: returning mocked objects while using a spied class failed
I am testing a class that has a private method "getEntityManager". This method returns an entity manager instance to be used in the public method "getAllProducts". So I use PowerMockRunner;
My dependencies…

saab
- 129
- 1
- 3
- 16
1
vote
3 answers
Javascript private methods: function expression vs function declaration
A common method of creating private methods (of sorts) in javascript is this:
Class = function (arg0, arg1) {
var private_member = 0;
var privateMethod = function () {
return private_member;
};
}
The above example could also…

Wingblade
- 9,585
- 10
- 35
- 48
1
vote
2 answers
Is it possible to use a static private method of a class as callback?
I saw code that contained the following line:
preg_replace_callback($regex, 'TextileParser::replaceAnchor', $text);
where TextileParser::replaceAnchor() is a private static method.

apaderno
- 28,547
- 16
- 75
- 90
1
vote
1 answer
Anonymous classes, private methods, and reflection
If I create an anonymous class with a private method, and try to access the method using reflection, it will throw an IllegalAccessException. However, if I call the method on the object before saving it to a variable, it works fine:
public class Z…

Ypnypn
- 933
- 1
- 8
- 21
1
vote
1 answer
Private function for operator overload
I am learning about operator overloading in C++. To try it out, I overloaded the [] operator to print the value at the index given. The code worked when I defined the operator overload member function as public.
However when I tried to do the same…

IEEE754
- 49
- 1
- 9