# Print out the instance methods defined class? or the path where the current class is?

**URL:** <https://forum.crystal-lang.org/t/print-out-the-instance-methods-defined-class-or-the-path-where-the-current-class-is/4771>\
**Category:** Help & Support\
**Created:** [July 12, 2022, 9:43am UTC](https://forum.crystal-lang.org/t/print-out-the-instance-methods-defined-class-or-the-path-where-the-current-class-is/4771 "2022-07-12T09:43:16Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![asterite](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/asterite/32/60_2.png) [@asterite](https://forum.crystal-lang.org/u/asterite)\
**Post date:** [July 12, 2022, 12:44pm UTC](https://forum.crystal-lang.org/t/print-out-the-instance-methods-defined-class-or-the-path-where-the-current-class-is/4771/2 "2022-07-12T12:44:51Z")

</div>

I’ve been thinking about this a lot these past days.

It’s tricky because Ruby is dynamic so everything is a VALUE and there’s a lot of runtime information that isn’t present in Crystal.

That said, I wonder if it would be nice for `Class` to provide methods like `subclasses`, `methods`, etc., that return runtime values. These can be used to quickly introspect types without having to open a browser or source code to see the API. Or they can be used to maybe generate documentation or transform the code to something else, like a schema. It’s tricky because type restrictions aren’t solved, so for now they can just be represented as strings.

So, the idea would be that `Class#sublcasses` doesn’t return an Array of Class. That’s kind of impossible. Same with `Class#methods`, there’s no existing type that we could return there.

But we could introduce intermediary types.

Here’s what I got so far:

[https://play.crystal-lang.org/#/r/dfjf](https://play.crystal-lang.org/#/r/dfjf)

Thoughts?

The nice thing about this is that all of this runtime information is only produced if asked. If you don’t call any of that nothing of that will exist at runtime.

You could also use this in the interpreter to quickly find out about methods and types (I just tried it and all the code runs fine in interpreted mode).

---

_[View the full topic](https://forum.crystal-lang.org/t/print-out-the-instance-methods-defined-class-or-the-path-where-the-current-class-is/4771)._
