Hi,
I wrote a small class containing 2 class methods for some calculations. I call those methods from another class.
I have declared everything properly in both classes and Xcode does not give any warnings.
Still, I checked with debugger and when I call method from this class it just doesn't invoke
THis is declaration:
+(double)Double...
I've got a module called AB. Right now it looks something like this:
module AB
extend self
def some_method(hash)
....
end
....
end
We use it like this: AB.some_method(:thing=>:whatever,:etc=>'you get the idea'). There are about a half-dozen strings that the user has to pass in that I'd like to turn into dynam...
I have a method like the following:
public void launch(String cmd, String [] args, String workingDir)
Inside this method I call ProcessBuilder.
How can I call ProcessBuilder including an arbitrary number of args included in my args parameter?
E.g., something like this:
ProcessBuilder pb = new ProcessBuilder(cmd, args);
I notice...
In the book Clean Code the author recommends breaking large methods into small functions that do one specific thing. In languages like Java this translates to pretty, readable code.
public static String renderPage(PageData pageData)
{
includeHeader(pageData);
includeContent(pageData);
includeFooter(pageData);
return page...
Hi
In my Python app, I'm using events to communicate between different plugins.
Now, instead of registering the methods to the events manually, I thought I might use decorators to do that for me.
I would like to have it look like this:
@events.listento('event.name')
def myClassMethod(self, event)
I have first tried to do it like thi...
class C1
unless method_defined? :hello # Certainly, it's not correct. I am asking to find something to do this work.
def_method(:hello) do
puts 'Hi Everyone'
end
end
end
So, how to judge whether a mehtod has defined or not?
...
Hi,
I want to override a method in the System.Resources.ResourceManager class in mscorlib v4.
I want to override the method GetResourceFileName like this;
protected override string GetResourceFileName(CultureInfo culture) {
string resourceFileName = base.GetResourceFileName(culture);
return resourceFileName.Replace...
I have a class definition that I've seen other define properties that return collections of objects.
Public Property GetAllAdults() as Adults
...
End Property
I made the argument that this should be a method in the class, because it doesn't define an attribute of the class, and could not be extended with parameters. Is/Are there reaso...
I need to interpose on a method call in a C++ program (the class resides in a separate shared library). I thought I could use LD_PRELOAD, but i am not sure how this would work (i only found examples of C functions): is there a way to setup interposition for a single method without copying over any code from the interposed class implement...
I looked at the similar questions and read some articles. THis article has some pictures which makes it clear.
SomeObject so = new SomeObject();
somefunction(so);
Console.write(so.x); // will print 1
SomeObject so1 = new SomeObject();
somefunctionByRef(so1);
Console.write(so1.x); // will print 1
static void somefunction(SomeObject s...
I have some methods for a class which return arrays like ["1", "3", "2", "6", "2"]. It is ok that these are string arrays, not numeric. I have another method that takes an array, and turns it into a single string like this 1 3 2 6 2.
class Turn
def initialize
@rolls = 1
@dice = []
end
def roll
@roll = []
x = 5 - @dice.le...
Hello,
I want to test if an object is deleted after a calling to my function executeDelete in order to send to the user an error if the object is still in my database.
if ($logement->isDeleted()) {
$this->getUser()->setFlash('notice', 'Suppression du logement effectuée');
}
else {
$this->getUser()->setFlash('error', 'Erreur lors de...
I have a list of strings. For each string in that list, I want to prepend another string. I wrote a method to do it, but I was wondering if there was something already in .NET I could use to do this. It seems like something that could be built in, but I was not able to find anything.
Here is the method I wrote:
Private Function Prepen...
What is the most appropriate sentinel method?
This breaks out of an infinite loop:
infinite loop
read in a value;
if (value == Sentinel) then exit;
process the value;
This uses duplicate code:
read in a value;
while (value != Sentinel)
process the value;
read in a value;
This uses a boolean variable i...
I have a C++ class which is meant to be inherited. All its children will inherit a method:
class Record {
public:
RETTYPE* all();
};
class Child : public Record {
int age;
char *name;
};
int main() {
Child boo;
Child boos* = boo->all(); // Pointer to array of Children
return 0;
};
How can I make a method retu...
Hi!
Is there any possibility to use the gettext functionallity within the CakePHP model validation array?
Usually a programmer would do it like this:
class Data extends AppModel
{
var $validate = array(
'title' => array(
'NichtLeer' => array(
'rule' => array('between', 4, 20),
'allowEmpty' => false,
'message' => _('B...
I'm doing a simple program regarding methods.
But I have one problem. Everything is already working except when looping.
When I choose to loop again. The program skips on inputting the name. And proceeds directly to the year and section.
Here's the code:
public static void main(String[] args) {
do{
System.out.println("Input info:")...
Sorry for this guys, but I really am unlucky today.
Please help, my problem a while ago was that I'm having problems while looping, and now it cannot loop at all. It won't let me enter the string to make it loop.
Name, and year and section also outputs as null. I also tried using try catch but it doesn't seem to be picking up any errors...
class Example(object):
def the_example(self):
itsProblem = "problem"
theExample = Example()
print(theExample.itsProblem)
How do I access a class's variable? I've tried adding this definition:
def return_itsProblem(self):
return itsProblem
Yet, that fails also.
...
Hi,
I'm trying to write a Python class that has the ability to do the following:
c = MyClass()
a = c.A("a name for A") # Calls internally c.create("A", "a name for A")
b = c.B("a name for B") # Calls internally c.create("B", "a name for B")
A and B could be anything (well, they're defined in a database, but I don't want to explicitly...