简体   繁体   English

smalltalk反射-如何获取方法名称?

[英]smalltalk reflection - how to get method name?

Assume I have a class and an instance method: 假设我有一个类和一个实例方法:

 ClassExample#methodExample
      ^"???"

Is there any way in Smalltalk to get the name of the method: Smalltalk中有什么方法可以获取方法的名称:

 var := ClassExample new.
 nameOfMyMethod := var methodExample.
 "nameOfMyMethod should be 'methodExample' (a string or symbol)"

?

I'm developing in VisualAge. 我正在VisualAge中进行开发。 Thanks for help! 感谢帮助!

Try this: 尝试这个:

methodExample
    ^(Processor activeProcess stackAtFrame: 0 offset: -9) selector

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM