digitalmars.D.learn - How to call one static method from another?
- Konstantin Kutsevalov (8/8) Jun 13 2016 Hi,
- Konstantin Kutsevalov (18/18) Jun 14 2016 May be my question was not enought clean...
- Andrea Fontana (7/25) Jun 14 2016 Simply:
- Konstantin Kutsevalov (3/31) Jun 14 2016 Yep, it's my mistake about "function" :)
- pineapple (2/4) Jun 14 2016 Also, typeof(this).method2();
- Steven Schveighoffer (3/7) Jun 14 2016 Yes, if you want to distinguish between another function named method2.
Hi, Just can't found information about "this" for static methods. Can anyone explain how to call current class from static methods? For example I have some class and I need to call some static method of current class from another static method. I don't like to use full class name for that, but I didn't know what need to use instead of "this". I sure it must be something like "self". :(
Jun 13 2016
May be my question was not enought clean... this is example of code: ``` class ClassName { public static void function method1() { // do something // and now I need to call other static method ClassName.method2(); // What I can use insted of full class name? // Like "self.method2()" } public static void function method2() { //... } } ```
Jun 14 2016
On Tuesday, 14 June 2016 at 07:20:47 UTC, Konstantin Kutsevalov wrote:May be my question was not enought clean... this is example of code: ``` class ClassName { public static void function method1() { // do something // and now I need to call other static method ClassName.method2(); // What I can use insted of full class name? // Like "self.method2()" } public static void function method2() { //... } } ```Simply: method2(); Anyway I guess you mean public static void method1() { } without "function" Andrea
Jun 14 2016
On Tuesday, 14 June 2016 at 07:35:36 UTC, Andrea Fontana wrote:On Tuesday, 14 June 2016 at 07:20:47 UTC, Konstantin Kutsevalov wrote:Yep, it's my mistake about "function" :) Thanks!May be my question was not enought clean... this is example of code: ``` class ClassName { public static void function method1() { // do something // and now I need to call other static method ClassName.method2(); // What I can use insted of full class name? // Like "self.method2()" } public static void function method2() { //... } } ```Simply: method2(); Anyway I guess you mean public static void method1() { } without "function" Andrea
Jun 14 2016
On Tuesday, 14 June 2016 at 07:35:36 UTC, Andrea Fontana wrote:Simply: method2();Also, typeof(this).method2();
Jun 14 2016
On 6/14/16 6:08 AM, pineapple wrote:On Tuesday, 14 June 2016 at 07:35:36 UTC, Andrea Fontana wrote:Yes, if you want to distinguish between another function named method2. -SteveSimply: method2();Also, typeof(this).method2();
Jun 14 2016