Hacker News new | past | comments | ask | show | jobs | submit login

I figured that Ruby must have similar functionality to Python's dir()

Sounds like you wanted

   'x'.methods
    => [:<=>, :==, :===, :eql?, :hash, :casecmp, ... ]
or the more focused

   'x'.methods - Object.methods
    => [:casecmp, :+, :*, :%, :[], ... ]

?



Yup - that's exactly what I was looking for. Awesome.


The question is why Python calls it "dir" when you just want to see a list of the object's methods...




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: