Simulating Algebraic Data Types (AKA tagged unions) and pattern matching them in C#

After programming for a bit in Scala I’ve fallen in love with functional programming. And given how concise the code is there’s not much to hate in it.

One of the fine features of Scala is an easy way of defining ADT’s.

Here’s a comparision of defining same ADT with C# and Scala:

Scala is a lot more concise, but that’s just the way C# is – noisy.

Now lets take a look on traditional approach of matching those.

Scala:

C#:

Good thing we can at least use some custom code and functional magic to make that similar to our C# version.

Given that we use this:

We can transform C# code into following:

Which isn’t perfect but is a whole lot nicer.

Unity3D is ommiting your .class files from Android plugin?

Hi there.

So… You want to add custom android code to your Unity3D game Android build, right?

The process is generally like this:

  1. Create an Android library project.
  2. Write your code.
  3. Package it in a .jar.
  4. Copy that .jar to YourUnity3DProject\Assets\Plugins\Android\
  5. Build Unity3D android build.

Except that for me my .class files were nowhere to be found in the final .apk.

The problem? My .jar was built using JDK7.

It seems that either Unity or DEX cannot handle JDK7 bytecode format. That’s all fine and all, but an error or at least a warning would be nice…

Solution: be sure to use JDK6 when you package your code to the .jar.