Tuesday, December 28, 2010

Easier object inspection in the Scala REPL

If you're like me, you spend a fair amount of time poking at objects of poorly documented classes in a REPL (Scala or otherwise...). This is great compared to writing whole test programs solely for the purpose of seeing what something does or what data it really contains, but it can be quite time consuming. So I've written a utility for use on the Scala REPL that will print out all of the "attributes" of an object. Here's some sample usage:

scala> import replutils._
import replutils._

scala> case class Test(a: CharSequence, b: Int)
defined class Test

scala> val t = Test("hello", 1)
t: Test = Test(hello,1)

scala> printAttrValues(t)
hashCode: int = -229308731
b: int = 1
a: CharSequence (String) = hello
productArity: int = 2
getClass: Class = class line0$object$$iw$$iw$Test

That looks fairly anti-climatic, but after spending hours typing objName. to see what's there, and poking at methods, it seems like a miracle. Also, one neat feature of it is that if the class of the object returned is different from the class declared on the method, it prints both the declared class and the actual returned class.

Code and further usage instructions is available on BitBucket here.

So what exactly is an attribute?

I haven't quite figured that out yet. Right now it is any method that meets the following criteria:

  1. the method has zero arguments
  2. the method is public
  3. the method is not static
  4. the method's name is not on the exclude list (e.g. wait)
  5. the method's return type is not on the exclude list (e.g. Unit/void)
  6. the method is not a "default argument" method
Please post any feedback in the comments here, or better yet in the issue tracker on Bitbucket.

Sphere: Related Content

52 comments:

olsonsfoodemporium said...

It won't really have success, I consider so.

Priya Kannan said...

This is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.I like it and help me to development very well.Thank you for this brief explanation and very nice information.Well, got a good knowledge.
PHP Training in Chennai

tommy shree said...

I am really happy with your blog because your article is very unique and powerful for new reader.
Click here:
Selenium Training in Chennai | Selenium Training in Bangalore | Selenium Training in Pune | Selenium Training in Chennai

Anbarasan14 said...

Thanks for your contribution in sharing such a useful information. Waiting for your further updates.

Computer Training Institute Franchise
Best Education Franchise In India
Training Franchise Opportunities In India
Education Franchise Opportunities In India
Top Education Franchises
Spoken English Franchise
Top Education Franchise In India

sandhiya arav said...

I am really enjoying reading your well written articles.
It looks like you spend a lot of effort and time on your blog.Keep Doing.
data analytics training in bangalore
Data Science Courses in Bangalore
Best Data Science Courses in Bangalore
data analytics courses in bangalore
big data analytics training in bangalore

Vicky Ram said...

Nice blog, more informative keep sharing

wblogin
Guest posting sites

sofiya said...

Really awesome blog. Your blog is really useful for me
Regards,
selenium training institute in chennai

jaya devan said...

You are doing a great job. I would like to appreciate your work for good accuracy
Regards,
best selenium training institute in chennai

service care said...

I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details.
redmi service center in chennai
mi service center in chennai

kavithasathish said...

Really a great blog for the people. Keep it up.
spanish language in chennai
spanish classes in chennai
German Classes in Chennai
IELTS Coaching in Chennai
Japanese Classes in Chennai
Spoken English Classes in Chennai
German classes in anna nagar
german classes in chennai anna nagar

VRITPROFESSIONALS said...

Nice post. Thanks for sharing! I want people to know just how good this information is in your article. It’s interesting content and Great work.
Thanks & Regards,
VRIT Professionals,
No.1 Leading Web Designing Training Institute In Chennai.

And also those who are looking for
Web Designing Training Institute in Chennai
SEO Training Institute in Chennai
Photoshop Training Institute in Chennai
PHP & Mysql Training Institute in Chennai
Android Training Institute in Chennai

mohit aggarwal said...

redbox tv apk

htop said...

thanks for sharing this information
angular js training institute in omr
azure training in chennai
best data science training in sholinganallur
best devops training in chennai
devops training in omr
best devops training institute in omr
best data science training in omr
data science training in siruseri

Lucky Patcher said...

movies123

Lucky Patcher said...

solarmovie

whatsapp plus themes said...

sports whatsapp groups

sabaribalaji said...

thanks for this informative article it is very useful
Machine learning taining in chennai
artificial intelligence and machine learning course in chennai
best machine learning training institute
top institutes for machine learning in chennai
machine learning course training institute in chennai
machine learning certification
machine learning training institutes
best institute to learn machine learning in chennai
machine learning course training
machine learning with r training in chennai

Admin said...

dtc bus app
dtc bus
dtc bus app download
dtc bus pass
dtc bus route
dtc bus route app
dtc bus app download

Admin said...

funny WiFi names
cool WiFi names
claver WiFi names
cool and claver WiFi names
funny WiFi names list
Good wifi names
wifi names 2020
Disney wifi names
wifi name for gamers
bollywood movies funny WiFi names

Hadoop Training said...

I Got Job in my dream company with decent 12 Lacks Per Annum salary, I have learned this world most demanding course out there in the current IT Market from the Data science courses in Pune experts who helped me a lot to achieve my dreams comes true. Really worth trying.

Unknown said...

Download Linda Ikeji Blog Apk Latest Version

MobilePriceall said...

Thanks for sharing such a great information with us. Your Post is very unique and all information is reliable for new readers. Keep it up in future, thanks for sharing such a useful post.
Here Is Daily Latest Updated Mobile Price for Bangladeshi People Who are looking for all mobile price to buy smartphone. I hope you guys will be like this Mobilepriceall Website. Thanks again.

Abhishek rajpoot said...

WhatsApp Status Video Download :WhatsApp introduced the status feature in 2015, in which we can share images, videos, and gifs as our story for 24 hours. Before this feature, WhatsApp had only text status option in which we can write our bio, but the new status feature is different. The story or status disappears after 24 hours and can’t be archived as still in WhatsApp.

Boy attitude status video download for whatsApp
Boy attitude status video download
Boy attitude status video download

Most romantic status video download for whatsApp
Sad video status download
Most Romantic status video download

video status download for whatsApp


we have latest & best collection of video status download for whatsapp

Abhishek rajpoot said...

WhatsApp Status Video Download :WhatsApp introduced the status feature in 2015, in which we can share images, videos, and gifs as our story for 24 hours. Before this feature, WhatsApp had only text status option in which we can write our bio, but the new status feature is different. The story or status disappears after 24 hours and can’t be archived as still in WhatsApp.

Boy attitude status video download for whatsApp
Boy attitude status video download
Boy attitude status video download

Most romantic status video download for whatsApp
Most Romantic status video download
Most Romantic status video download

video status download for whatsApp


we have latest & best collection of video status download for whatsapp

khushboo said...

The registrations and auditions for the Bigg Boss 13 are going to start soon. The official list of contestants is not yet announced by the officials. That will be announced by the makers on the inaugural day which is 15 the of September. bigg boss 13 contestants name list with photo Though a few rumored names are coming up as the expected celebrity contestants of the year. They are Nia Sharma, Raghav Juyal, Punit Pathak, Divyanka Tripathi, Garima Chaurasia, Ridhima Pandit, Aditya Narayan, Jasmin Bhasin, Zain Imam, Bhuvan Bam, Chetna Pande, Krystle D’Souza, and Devoleena Bhattacharjee. This year too, the show will be back with a new theme and the star host, Salman Khan. Though the theme is not declared yet officially. Stay tuned with us to know more about the show Bigg Boss 13.

Vijiaajith said...

Nice...
freeinplanttrainingcourseforECEstudents
internship-in-chennai-for-bsc
inplant-training-for-automobile-engineering-students
freeinplanttrainingfor-ECEstudents-in-chennai
internship-for-cse-students-in-bsnl
application-for-industrial-training

Vijiaajith said...

nice
interview-questions/aptitude/permutation-and-combination/how-many-groups-of-6-

persons-can-be-formed


tutorials/oracle/oracle-delete

technology/chrome-flags-complete-guide-enhance-browsing-experience/

interview-questions/aptitude/time-and-work/a-alone-can-do-1-4-of-the-work-in-2-days


interview-questions/programming/recursion-and-iteration/integer-a-40-b-35-c-20-d-10-comment-about-the-output-of-the-following-two-statements

Unknown said...

All The Interested Candidates Read The Notification of The Following Vacancy. Read and Check Are You Eligible For This Vacancy and Read The How to Apply The Online Form of This Job. Online Quran Classes For Kids

Admin said...

Dr Driving is one of the my favourite game ever and today I am going to share Dr Driving Mod Apk
https://www.drdrivingmodapk.xyz/

Vijiaajith said...

Nice
Permutation and Combination Aptitude Interview Questions
Oracle Delete
Time and Work Aptitude Interview Questions
Chrome Flags Complete Guide Enhance Browsing Experience
Recursion and Iteration Programming Interview Questions
Apache Pig Subtract Function
Xml Serializer there was an Error Reflecting Type
Simple Interest Aptitude Interview Questions
Compound Interest Aptitude Interview Questions
Specimen Presentation of Letters Issued by Company

Vijiaajith said...

very nice
ece internship
data science training in chennai
Internship in Chennai
Internship at Chennai
Internship Chennai
IT Internships
Online Internship
MBA internship

Vijiaajith said...

internship for b.arch students in chennai
mechanical internship in chennai
internship for ece students
big data training in chennai
free internship for cse students in chennai
automobile internship in chennai
robotics course in chennai
internship in chennai

smartdeveloper said...




the c.p of 15 books is equal to the s.p of 18 books. find his gain% or loss%?
integer a=40 b=35 c=20 d=10
javascript int max
react native resume
qdxm:sfyn::uioz
a merchant sold an article at 10% loss. if he had sold it rs 450 more, 8% would have been gained on the cost price. find the cost price?
a watch was sold at a loss of 10%. if it was sold for rs.140 more, there would have been a gain of 4%. what is the cost price?
flipkart hack apk
hack flipkart
how to hack mobile phones with computer using cmd

smartdeveloper said...


inplant training in chennai

implant training in chennai

internship for cse 3rd year students

inplant training

in plant training in chennai

inplant traning in chennai

internship for bca 2nd year

internship in chennai for ece

internship in chennai for cse

inplant

parvina said...

Very nice blog. It is very useful for us. Thanks for good information.Visit here :x ray camera app

Yunus Ali said...

I Love your article. You can visit my website : stardew valley slingshot game

watson said...

Awesome,Thank you so much for sharing such an awesome blog. digital marketing training in bangalore

Customer relationship management said...

Your articles really impressed for me,because of all information so nice.servicenow training in bangalore

Customer relationship management said...

These provided information was really so nice,thanks for giving that post and the more skills to develop after refer that post.opennebula training in bangalore

Customer relationship management said...

I gathered a lot of information through this article.Every example is easy to undestandable and explaining the logic easily.openstack training in bangalore

Customer relationship management said...

Very useful and information content has been shared out here, Thanks for sharing it.salesforce developer training in bangalore

Customer relationship management said...

This is really an awesome post, thanks for it. Keep adding more information to this.vmware training in bangalore

watson said...

Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from Dot Net Training in Chennai. or learn thru ASP.NET Essential Training Online . Nowadays Dot Net has tons of job opportunities on various vertical industry.citrix training in bangalore

watson said...

thank you so much for this nice information Article, Digitahanks for sharing your post with us.WEBMETHODS training in bangalore

watson said...

This is amazing and really inspiring goal.Hadoop Training in Bangalore

watson said...

It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful. PEGA PPRC training in bangalore

watson said...

I have read your blog its very attractive and impressive. I like it your blog.Informatica Training in Bangalore

watson said...

Great post!I am actually getting ready to across this information,i am very happy to this commands.Also great blog here with all of the valuable information you have.Well done,its a great knowledgez. IMSBI Training in Bangalore

Softgen Infotech said...

Such a great word which you use in your article and article is amazing knowledge. thank you for sharing it.

Looking for Best Training Institute in Bangalore , India. Softgen Infotech is the best one to offers 85+ computer training courses including IT Software Course in Bangalore , India. Also, it provides placement assistance service in Bangalore for IT.

rajan said...

inplant training in chennai
inplant training in chennai
inplant training in chennai for it.php
chile web hosting
colombia web hosting
croatia web hosting
cyprus web hosting
bahrain web hosting
india web hosting
iran web hosting

Softgen Infotech said...

Post is very useful. Thank you, this useful information.

Learn Best SAP S4 HANA Simple Finance Training in Bangalore from Experts. Softgen Infotech offers the Best S4 HANA Simple Finance Training in Bangalore.100% Placement Assistance, Live Classroom Sessions, Only Technical Profiles, 24x7 Lab Infrastructure Support.

meritstep1 said...

I just loved your article on the beginners guide to starting a blog.If somebody take this blog article seriously in their life, he/she can earn his living by doing blogging.thank you for thizs article. pega online training , best pega online training ,
top pega online training