static-methods Questions

2

Solved

I am trying to verify in a test that a static method is called. I am using Mockito for this purpose. This question is similar to this. However, the solution suggested in the most upvoted reply is n...
Freaky asked 24/8, 2021 at 7:19

6

Solved

assume following class definition: class A: def f(self): return 'this is f' @staticmethod def g(): return 'this is g' a = A() So f is a normal method and g is a static method. Now, how ...
Swindle asked 4/1, 2012 at 12:42

2

Solved

.NET 7 recently introduced IParsable as an interface, and I'd like to check for its presence. Some test that will return true if T implements IParsable<T> and false otherwise. Say I want to r...
Pinnatiped asked 19/11, 2022 at 17:6

7

Solved

I have a Python module that contains a number of classes, each representing a particular physical material with its properties (e.g., density, specific heat). Some of the properties are just float ...
Crinkumcrankum asked 19/2, 2014 at 14:31

5

Solved

Is it possible to have a static property on a class that would be computed as a one off. The idea would be to be able to do it like so: class Foo: static_prop = Foo.one_off_static_method() @sta...
Zimmerman asked 14/9, 2016 at 20:12

8

Solved

When I attempt to use a static method from within the body of the class, and define the static method using the built-in staticmethod function as a decorator, like this: class Klass(object): @sta...
Zobias asked 3/10, 2012 at 23:12

3

Solved

Let's say in Java, I have class CryptoFormat, which has a static method named getLegacyFormat(). When I want to use the method, I just need to call CryptoFormat.getLegacyFormat(). This is clear bec...
Dispensable asked 9/7, 2017 at 0:12

8

Solved

I have this method that I want to use $this in but all I get is: Fatal error: Using $this when not in object context. How can I get this to work? public static function userNameAvailibility() { ...
Moten asked 18/2, 2010 at 6:18

3

Solved

Why are static methods supported from Java 8? What is the difference between the two lines in main method in below code? package sample; public class A { public static void doSomething() { Syst...
Bal asked 20/8, 2017 at 10:7

1

I'm working on this Python module, which compounded from several files. Few of those files are actually independents, and meant to do a very specific job. I know for a fact that there will be only ...

2

Solved

I am trying to mock static method using EasyMock+PowerMock. If I dont mock the static method, then I get the exception java.lang.ExceptionInInitializerError but with a different stack trace which i...
Errand asked 30/7, 2016 at 23:29

3

Solved

I have a webform and in that webform, I am trying to access a Panel object from a static method, but couldn't access it How can I access a Panel object from static method. Why am I trying to access...
Hatcher asked 4/2, 2013 at 10:40

25

Solved

I am wondering when to use static methods? Say if I have a class with a few getters and setters, a method or two, and I want those methods only to be invokable on an instance object of the class. D...
Bureaucratic asked 19/4, 2010 at 23:5

10

Let's say I have, or am going to write, a set of related functions. Let's say they're math-related. Organizationally, should I: Write these functions and put them in my MyMath namespace and refer...
Antennule asked 16/9, 2009 at 19:15

11

Solved

I was just reading over the text given to me in my textbook and I'm not really sure I understand what it is saying. It's basically telling me that static methods or class methods include the "...
Eijkman asked 16/8, 2012 at 18:15

29

Solved

There is no static keyword in Kotlin. What is the best way to represent a static Java method in Kotlin?
Leatherworker asked 1/11, 2016 at 0:52

2

Solved

in javaFX Application is an abstract class. In this abstract class there have some abstract methods which are overridden in main class which extends abstract Application class and also have static ...
Incommunicative asked 30/7, 2023 at 15:1

5

Solved

I've worked with a few different languages such as Java, C#, and Objective-C. In most languages, methods that don't require an instance of an object are called static methods. However, when it com...

5

Solved

I have a code like that: User = function(){} User.a = function(){ return "try"; } User.b = function(){ } ​ From User.b() I can call User.a() using: User.b = function(){ return User.a(); ...
Dimmick asked 28/6, 2012 at 16:30

2

Solved

Why can't I make a class' __call__ method static using the @staticmethod decorator? class Foo(object): @staticmethod def bar(): return 'bar' @staticmethod def __call__(): return '__call__' ...
Throttle asked 7/11, 2014 at 3:32

2

Solved

Calling Python static methods using the class name is more common, but can be a real eye sore for long class names. Sometimes I use self within the same class to call the static methods, because I ...
Cathedral asked 27/12, 2020 at 0:23

36

Solved

What is the difference between a method decorated with @staticmethod and one decorated with @classmethod?
Expensive asked 25/9, 2008 at 21:1

7

Solved

Right now I have this code to check to which table an Eloquent model is connected into. $s = new Something(); dd($s->getTable()); Is there anyway I can get the table without instantiating new...
Hesione asked 23/8, 2018 at 7:32

3

My Java code: public class Common { public static ModelPengguna currentModelPengguna; }
Beeck asked 9/6, 2019 at 12:15

10

Solved

How do you define a static extension method in Kotlin? Is this even possible? I currently have an extension method as shown below. public fun Uber.doMagic(context: Context) { // ... } The above...
Entrenchment asked 29/1, 2015 at 8:35

© 2022 - 2025 — McMap. All rights reserved.