Initialize dictionary at declaration using PowerShell

No. The initialization syntax for Dictionary<TKey,TValue> is C# syntax candy. Powershell has its own initializer syntax support for System.Collections.HashTable (@{}): $drivers = @{“nitrous”=”vx”; “directx”=”vd”; “openGL”=”vo”}; For [probably] nearly all cases it will work just as well as Dictionary<TKey,TValue>. If you really need Dictionary<TKey,TValue> for some reason, you could make a function that takes a HashTable … Read more

Does Python do variable interpolation similar to “string #{var}” in Ruby? [duplicate]

Python 3.6+ does have variable interpolation – prepend an f to your string: f”foo is {bar}” For versions of Python below this (Python 2 – 3.5) you can use str.format to pass in variables: # Rather than this: print(“foo is #{bar}”) # You would do this: print(“foo is {}”.format(bar)) # Or this: print(“foo is {bar}”.format(bar=bar)) … Read more

Is there const in C?

There are no syntactic differences between C and C++ with regard to const keyword, besides a rather obscure one: in C (since C99) you can declare function parameters as void foo(int a[const]); which is equivalent to void foo(int *const a); declaration. C++ does not support such syntax. Semantic differences exist as well. As @Ben Voigt … Read more

Disadvantages of Scala type system versus Haskell?

The big difference is that Scala doesn’t have Hindley-Milner global type inference and instead uses a form of local type inference, requiring you to specify types for method parameters and the return type for overloaded or recursive functions. This isn’t driven by type erasure or by other requirements of the JVM. All possible difficulties here … Read more

What are the PowerShell equivalents of Bash’s && and || operators?

Update: && and || have finally come to PowerShell (Core), namely in v7, termed pipeline-chain operators; see this answer for details. Many years after the question was first asked, let me summarize the behavior of Windows PowerShell, whose latest and final version is v5.1: Bash’s / cmd‘s && and || control operators have NO PowerShell … Read more

YAML compared to XML [closed]

YAML is much less verbose. The signal-to-noise ratio is higher without all the brackets. This makes it subjectively easier to read and edit for many people. On the flip side, it’s slightly (only slightly) harder to parse. The biggest difference, though, is that XML is meant to be a markup language and YAML is really … Read more