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

39 comments:

olsonsfoodemporium said...

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

Unknown 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

sandhiya 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

Anonymous said...

Really awesome blog. Your blog is really useful for me
Regards,
selenium training institute 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

Anonymous 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

whatsapp plus themes said...

sports whatsapp groups

Devender Gupta said...

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

Devender Gupta 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

Prwatech 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.

bataiu said...

Download Linda Ikeji Blog Apk Latest Version

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

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
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

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

parvina said...

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

Lily said...

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

Realtime Experts 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

Realtime Experts 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.

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.

pnjsharptech said...

PNJ Sharptech is a leading Social Media Optimization company in India, specializing in handling both organic and paid Social Media Marketing (SMM) campaigns successfully. We have many years of experiencing increasing online social presence on various social media platforms such as Facebook, Twitter, LinkedIn and Pinterest, and many others. Our SMO experts have a rich knowledge of increasing traffic and maintaining the online social reputation for a long period. How our SMO services make you different from others? Our low-cost social media marketing services are very helpful to build your online reputation and increase sales.

Ismail said...

Thanks for sharing this information...
Informatica Training in Bangalore

nisha said...

Nice Blog. thanks for sharing. every content should be very uniquely represented.

Data Science Training Course In Chennai | Data Science Training Course In Anna Nagar | Data Science Training Course In OMR | Data Science Training Course In Porur | Data Science Training Course In Tambaram | Data Science Training Course In Velachery

suresh said...

Thank you so much for this nice information. Hope so many people will get aware of this and useful as well. And please keep update like this.
DevOps Training in Chennai

DevOps Course in Chennai

Pathway for German Language said...
This comment has been removed by the author.
OGEN Infosystem (P) Limited said...

Interesting article, thank you so much for sharing this amazing blog with us. Visit Ogen Infosystem for creative Website Designing and SEO Services in Delhi, India.
Best Website Designing Company in India

R ADK said...

Software IT Coaching Center in ChennaiOrganic Chemistry tutor

Rahul Sharma said...

This is Great Article. You are post informatics blog so keep posting.
Service providers’ app
Best SEO agency in Meerut
graphic design company in Delhi NCR
Top 10 CBSC Schools in Meerut
Desawe Satta King
Digital Marketing Service
Delhi Desawer Satta Bazar
Latest News in Hindi

Block said...

I simply wanted to thank you so much again. I am not sure the things
that I might have gone through without the type of hints revealed by
you regarding that situation.
oracle certification in Chennai
asp net training in Chennai
C # Training in Chennai

Valentines Day Wishes 2021 said...

this is a pounding blog. I wind it. you have such a lot of mastery about this depend, and as a repercussion a ton enthusiasm. You further to know a method for making individuals rally toward the back it, clearly from the reactions. Microsoft Office 2016 Product key Generator

Syedhaseebulhassan said...

A huge substance material as wonderfully as enormous organization. Your site justifies each and every one of the positive information its been getting. I might be advance quickly for pulling taking locale streams contents.! Good Morning Refreshing Quotes

UnoGeeks said...

Oracle Recruiting Cloud Training

Anonymous said...

What a nice blog post, and Many thanks for supplying this information. 스포츠토토

Anonymous said...

Thank you so much for the post perusing this one. Continue posting. Much obliged for sharing 토토