Boo vs. PowerShell

Link. May 10, 2007. Comments [2]. Posted in: PowerShell

Oren (Ayende) wrote a cool little script in Boo showing how to count the number of types and methods in mscorlib. Just for fun, here's an equivalent script in PowerShell that does the same thing:

[System.Object].Assembly.GetTypes() | foreach { 
   $typeCount++ 
   $methodCount += $_.GetMethods().Length
}
"Types $typeCount, Methods $methodCount"

This is, of course, just one possible way to write it.



Sunday, May 13, 2007 12:38:11 PM (SA Pacific Standard Time, UTC-05:00)
[System.Object].Assembly.GetTypes() | %{$_.GetMethods().Length} | measure-object -sum
oneliner
Tuesday, June 05, 2007 9:23:02 PM (SA Pacific Standard Time, UTC-05:00)
I just picked up powershell today, I'm hooked!

[System.Object].Assembly.GetTypes() | foreach {
$_.Name; $_.GetMethods() | foreach{"-==-"+$_.Name}
}
"Types $typeCount, Methods $methodCount"
Comments are closed.

Syndicate

About

Tomas Restrepo is a software developer located in Colombia, South America. His interests include .NET, Connected Systems, PowerShell and lately dynamic programming languages. More...

tomasrestrepo @ twitter My Flickr photostream My saved links on delicious My Technorati Profile

email: tomas@winterdom.com
msn: tomasr@passport.com

View my profile on LinkedIn

MVP logo

Ads


Links

Categories

Statistics

Total Posts: 1022
This Year: 92
This Month: 11
This Week: 0
Comments: 792

Blogroll

Post Archive

Other

Copyright © 2002-2008, Tomas Restrepo.

Powered by: newtelligence dasBlog 2.1.8139.823

Sign In