开发者

Is there a smalltalk "toString" equivalent?

开发者 https://www.devze.com 2023-02-19 02:59 出处:网络
For example, let\'s say I 开发者_JAVA百科am adding a set of objects I created, called myClass (which contains a string) to myList and then I wish to use the list and pass it to a GUI list. Is there a

For example, let's say I 开发者_JAVA百科am adding a set of objects I created, called myClass (which contains a string) to myList and then I wish to use the list and pass it to a GUI list. Is there a way to populate that GUI list only with the value of that string in myClass?


Every object should respond to printString message with some meaningful string presentation of itself. You can write your own #printString for your object and use it.

Even better for your case could be implementation of asString conversion method, which converts your object to a string.


I believe the methods you are looking for are printString and/or displayString.

0

精彩评论

暂无评论...
验证码 换一张
取 消