Questions tagged [private-methods]

285 questions
1
vote
1 answer

Should stdlib classes with emplace-mechanisms be friendable?

I am wondering if this an stdlib bug, an oversight, my own error or intended by the standards committee. If a type T's constructor (any of its constructors) is non-public, an unrelated container cannot emplace an element using that constructor,…
bitmask
  • 32,434
  • 14
  • 99
  • 159
1
vote
2 answers

Can I temporarily make all Ruby methods public?

I'm reproducing a bug in my Rails console. I'm interested in what some methods return, but some of them turn out to be private, so in my console I have to write: > my_object.my_method NoMethodError (private method `my_method' called for…
Simon
  • 25,468
  • 44
  • 152
  • 266
1
vote
1 answer

Call private or protected method from an include file

myclass.php class myclass { private $name; public function showData(){ include_once "extension.php"; otherFunction($this); } private function display(){ echo "hello world!"; } } extension.php function otherFunction($obj){ …
CMS scripting
  • 669
  • 1
  • 7
  • 13
1
vote
2 answers

Access to a private method in C#

Hi People I'm newbie in the C# world and I'm having a problem. I have done an array in the Form_Load method of my program, but I need to access the array in a picture_box method like this: private void Form2_Load(object sender, EventArgs…
Andres
  • 351
  • 1
  • 4
  • 11
1
vote
2 answers

How to ignore or fix error TS2341: Property 'myFunction' is private and only accessible within class 'MyClass' with Jest 24 and Angular 8

I'm using Jest 24 with my Angular 8 app. When a try to test a private function on a component, a TS2341 error is thrown. Something like : error TS2341: Property 'myFunction' is private and only accessible within class 'MyClass' Is there a way to…
j.2bb
  • 881
  • 3
  • 10
  • 17
1
vote
1 answer

How to get acornjs to properly style check private class fields and methods?

I'm working on a project where I need to use a style check for my code. I want to use acorn js, however it fails when trying to parse private class fields and class methods. I've tried: const { Parser } = require('acorn'); const privateMethods =…
Alex
  • 131
  • 2
  • 13
1
vote
1 answer

Ruby RSS -- Private method send called for RSS:REXMLListener

I am trying to integrate a RSS parser into my IRC bot, and i've found some simple code to do so online, however, if i put this code in the bot, I get this: Error: private method `send' called for # I'm not sure why it…
umby24
  • 11
  • 2
1
vote
2 answers

Unit tests, private methods and hidden abstraction

I was reading about unit tests, to learn a bit more about that. It seems that tests private methods shouldn't be the general rule, only some exceptions. I have find this article, in which explains that:…
Álvaro García
  • 18,114
  • 30
  • 102
  • 193
1
vote
0 answers

Websocket with kraken closes after sending subscription for open position

I am trying to subscribe to the kraken websocket API for the OpenPositions. I have sent a challenge request and receive the challenge , i also have signed it correctly with my secret key but it seems like once i sent the openpositions subsctiption…
1
vote
0 answers

Unit testing a private callback factory

I am trying to create unit tests for a private callback factory with an alarm manager class. I don't want to test the private method directly as I think this contravenes TDD good practice but I cannot figure out a good way to test this. Please…
rmasp98
  • 97
  • 1
  • 6
1
vote
1 answer

Should private methods check if object is properly initialized

Should the private methods of a class check if the object is properly initialized even if it's already done by the public methods? I have an class/object that represents real hardware. What the private methods do can be dangerous if object is not…
1
vote
2 answers

How to make an inherited method private in extended class

I want to make an inherited method private outside of the extended class in Typescript Let's say I have two classes like this: class BaseClass{ constructor(){} sayHello(){ console.log('hello'); } } class Class extends…
hkonsti
  • 85
  • 1
  • 1
  • 6
1
vote
1 answer

access private class method from trait in PHP

I want to call a private class method from trait. If I do $this->privateMethod(); the call is made. Since I want to only call that method if exists, I've implemented a isCallable() function; but this function is returning false when I was expecting …
Matías Cánepa
  • 5,770
  • 4
  • 57
  • 97
1
vote
1 answer

How to access public members in private method in R6Class?

library(R6) Person<-R6Class("Person", public=list( name=NULL, age=NULL, initialize=function(name,age){ self$name<-name self$age<-age }, GrowUP1=function(){ self$publicGrow() }, …
beginner
  • 13
  • 6
1
vote
2 answers

Access an object from another class in private method

How do I access an object from another class in private method in Java ? Simple example to call private method from another class. File: A.java public class A { private void message(){System.out.println("hello java"); } } File:…
Aja
  • 23
  • 9