How do I find which messages an object understands?
Asked Answered
I

3

5

In Pharo, I know that integers understand the message to:. The workspace offers suggestions:

workspace suggestions

But if I inspect an integer from the workspace, it doesn't mention to::

inspecting integer

Searching for SmallInteger doesn't show anything in the system browser either:

system browser

How do I discover which messages I can send to objects? Ideally I'd like to see their source code too.

Immobilize answered 5/6, 2014 at 21:16 Comment(0)
H
5

Revisiting your question I noticed that, in your last screenshot, you did not search for the class SmallInteger but for a package named SmallInteger. This Package does not exist.

But you probably wanted to search for the class SmallInteger. This is done by the keyboard shortcut Cmd-F Cmd-C (Alt-F Alt-C on Linux) or by selecting Find Class… in the context menu of the class panel of the Nautilus system browser. This lets you browse the methods implemented in SmallInteger. If you work up your way through the superclasses you can have a look at all messages understood by an instance of SmallInteger.

enter image description here

Homestretch answered 5/6, 2014 at 21:49 Comment(2)
Note that if you just type '1 browse' and do it, you'll open the hieararchy browser as presented above. Or if you type '1' inspect it, open a class browser from the inspector.Froghopper
also, you can find classes using the spotlight: shift+enter then type the class name your are looking for.Nicol
H
4

Each class understands the message allSelectors.
allSelectors answers a set of all the message selectors that instances of the receiver can understand. This includes all messages selectors in the method dictionary of the receiver and in the method dictionaries of it’s superclasses.

So try and print or better, inspect:

1 class allSelectors.
Homestretch answered 5/6, 2014 at 21:39 Comment(0)
M
4

Also, you can just type the name of the class wherever you want, select it, then press command+B (browse). That'll bring up a browser on said class.

Modestia answered 6/6, 2014 at 8:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.