The Crystal Programming Language Forum

How to know the reciever or namespace of a methods being called?

I know the question is odd. I realized #gets can get input from stdin, then I tried to look up the API doc to know which gets being called, since there are IO, IO::Memory… They all have gets methods.

I am not sure If I made myself clear.

Since there is nothing before the method name, i.e. its just gets, it would be the method on the top level namespace, https://crystal-lang.org/api/master/toplevel.html#gets(*args,**options)-class-method.

It essentially is just a wrapper to https://crystal-lang.org/api/master/IO.html#gets(delimiter:Char,limit:Int,chomp=false):String?-instance-method called on STDIN.

2 Likes