Event 3: My notes…

Time to summarize 3rd event of Scripting Games 2013. I must admin – I learn few new tricks while reading entries for this event. But I still see some things I really can’t stand. Especially in beginner category, where many people decided that putting everything in one line makes it “special”. It doesn’t. If you still think it does – read this article by Richard Siddaway. If you still think line break is cursed – read it again. Repeat. Puszczam oczko

Continue reading

AST ‘splatting’ with static methods.

PowerShell-Splatting-With-StaticHave you ever wanted to use splatting outside it’s normal use with PowerShell commands? Splatting is great to pass (named) parameters to commands, but there are other elements that have named parameters. Perfect example: static methods that exist on .NET types. Unfortunately, in current version of PowerShell we can’t extend splatting concept to other language elements. But I guess a lot of people would agree with me: it would be great to be able to do something like:

$ToSplat = @{            
    format = "Using 'splatting' hashtable: {0:N2} and {1:N3}"            
    args = [math]::PI, [math]::E            
}            
            
[string]::Format(@ToSplat)

It may happen one day, but can we do anything about it now? Well… sure!

Continue reading