While working at my desk, catching an occasional glimpse of a mist-laden Jersey shoreline from the window, a friend of mine, a soft-spoken British computer game developer, and I chatted to each other from across the Atlantic.
Specifically, we were chatting about the inner particulars of Ruby and the implications of a purely object-oriented paradigm upon its objects and classes. He steered me to open up a session of Pry (a read-eval-print-loop environment), and gave some instructions:
“Navigate into the kernel.”
cd Kernel
“Look around you, do you see anything?”
ls
“Ah, glorious. We have our Kernel methods…”
“Yes. Navigate into String and look around.”
cd String
… ls
“I don’t see much, other than some… locals.”
“Yes. Now, try creating an instance of a String.”
x = "wombat"
“Navigate into that instance, look around.”
cd x
… ls
“Tell me, what do you see?”
Comparable methods: < <= > >= between?
String methods: % * + << <=> == === =~ [] []= asc
nly? bytes bytesize capitalize capitalize! casecmp center chars chomp chomp! chop chop! chr clear codepoints concat count crypt delete delete! downcase downcase! dump each_byte each_char each_codepoint each_line empty? encode encode! encoding end_with? eql? force_encoding getbyte gsub gsub! hash hex include? index insert inspect intern length lines ljust lstrip lstrip! match next next! oct ord partition replace reverse reverse! rindex rjust rpartition rstrip rstrip! scan setbyte shell_split shellescape shellsplit size slice slice! split squeeze squeeze! start_with? strip strip! sub sub! succ succ! sum swapcase swapcase! to_c to_f to_i to_r to_s to_str to_sym to_unix tr tr! tr_s tr_s! unpack upcase upcase! upto valid_encoding?
self methods: __binding_impl__
locals: _ _dir_ _ex_ _file_ _in_ _out_ _pry_
I found myself pausing and catching my breath a few times; I felt as though I was observing small glyphs scrawled across stone walls of a dark labyrinth.
I stepped, tentatively. And then:
“Ah! But of course! It makes sense. ‘x’ is an instance of String, so asking for its methods will provide the instance methods of String, while asking for the methods of the class String will provide the class methods.” (Cryptic not, are the glyphs!)
Long after we left the subject, I would intermittently retrace my way back to the labyrinth, typing and summoning the names of various unsuspecting objects and gazing at their inner methods. Actually, I had that window open for the rest of the day, and when I finally exited the session, I was only able to do so by self-coercion.
I was lingering, embryonic, in the kernel, conversing with the clues embedded in the corners- and I was feeling far from finished.