Questions tagged [private-methods]

285 questions
1
vote
6 answers

accesing private static method from another

I have main class with a private static method. I want to access this method from another java class. I tried some ways,however they didnt work. How can I access the method? below main class like this; public class RandomGenerate { public…
Deniz
  • 127
  • 1
  • 5
  • 14
1
vote
0 answers

Only show page content if from same server for .load() script

I'm loading HTML content via .load() for tooltips, and have been trying to figure out if there is a way to limit access to the HTML content outside of the script. For example: jQuery("#content_here").load("path/to/content/" + requested_content +…
taylor
  • 509
  • 1
  • 9
  • 22
1
vote
2 answers

Private Method in Module Pattern: TypeError: undefined is not a function

I am trying to implement a classic Module Pattern in javascript, discussed here and here. But my private methods are not working. I have the following bit of testing code. var jsStuff = (function() { // Private var sayStuffPrivate =…
Dave
  • 822
  • 1
  • 7
  • 17
1
vote
1 answer

private method 'save' called for # (NoMethodError)

From following a tutorial, I have this instance method for class Guide, which has an inner class, class Config: def add puts "\nAdd a restaurant\n\n".upcase restaurant = Restaurant.new print "Restaurant name: " restaurant.name…
super_J
  • 234
  • 2
  • 10
1
vote
1 answer

Basic mocking techniques

I am new to mocking and stubbing. I have to write unit tests to a class, which I cannot redesign. It is what it is. The class has public methods that have to be tested. These public methods use private methods to perform external calls to web…
Ramzay
  • 181
  • 4
  • 12
1
vote
1 answer

Code is wont output what i input, and wont calculate the input numbers

So this is a calculator problem. We are to have a Calculator class (which contains the other three classes), Number class (for type-checking the quantities to be processed), Operation class (for the five operations)), and Memory class (for the…
kenea11
  • 19
  • 2
1
vote
0 answers

How to create a library (Ansi C) with private functions in linux?

I am trying to create a library (static or shared) that has only a specified functionality accessible for those who use that library. If I generate the library as follows, all functions implemented in the library are usable from an external…
crossmax
  • 346
  • 3
  • 20
1
vote
1 answer

Where are the private members of an anonymous immediate function stored?

Take for example: var myobj; // this will be the object (function () { // private members var name = "my, oh my"; // implement the public part // note -- no `var` myobj = { // privileged method getName:…
1
vote
1 answer

Javascript calling a private method with ()() - parentheses after parentheses

I was playing with private methods and I have accidentally found out, that I can call a method, which calls a private method using ()() - double parentheses instead of assigning it to variables couple of times. Here is my code to make it…
Alex
  • 283
  • 1
  • 2
  • 12
1
vote
1 answer

In Scala, how do I access a case class's private constructor from its companion object

I have the following code defined (in Scala IDE/Scala Worksheet with Scala 2.10): object WorkSheet1 { object A { def apply(s: String, huh: Boolean = false): A = A(s) } case class A (s: String) //case class A private (s: String) val a =…
chaotic3quilibrium
  • 5,661
  • 8
  • 53
  • 86
1
vote
2 answers

php class inheritance private method not calling properly in child (extended) class

class A { public function x() { echo "Public function in class A
"; } private function y() { echo "Private function in class A
"; } public function expose() { $this->x(); …
Robert
  • 10,126
  • 19
  • 78
  • 130
1
vote
3 answers

When is it useful to use a private constructor?

Possible Duplicate: What is the use of making constructor private in a class? When is it useful to use a private constructor? What about a protected one?
Ali_IT
  • 7,551
  • 8
  • 28
  • 44
1
vote
2 answers

Mock the external call under private method in java

I want to test the ClassToTest class for it's method methodToTest. But I am not able to make it as the private method anotherMethod which is being called by the methodToTest has some dependency with the value returned by the singleton class…
1
vote
2 answers

Hidden instance variables in before_filter method

Is it a good practice to hide instance variable initialization in private methods? For example, I have a user controller with some actions: class UsersController < ApplicationController before_filter :get_user, only: [:show, :edit, :update,…
1
vote
1 answer

XCode: Duplicate Symbol

I have a C function heightParameter that is a simple tool that I use in a couple of my UIViewControllers. I am declaring this only in my main implementation of each UIViewController subclass (in the .m) above my other functions, so that I didn't…
RileyE
  • 10,874
  • 13
  • 63
  • 106