Ruby: how the interpreter parses your code

I wasn’t sure exactly how the Ruby code I’d written was being interpreted.

For example, 

class TestClass

def initialize(x = 1)

@x = x


puts “inside the class”


a =

puts “declared an instance”

Now, does this print “inside the class” or “declared an instance” first?

The answer is “inside the class”.

See also this post describing using Ripper to parse code: 

Leave a Reply

Your email address will not be published. Required fields are marked *