Skip to content

Instantly share code, notes, and snippets.

@rgarner
rgarner / hash_deep_diff.rb
Created July 1, 2016 09:57 — forked from henrik/hash_deep_diff.rb
Recursively diff two Ruby hashes.
# Recursively diff two hashes, showing only the differing values.
# By Henrik Nyh <http://henrik.nyh.se> 2009-07-14 under the MIT license.
#
# Example:
#
# a = {
# "same" => "same",
# "diff" => "a",
# "only a" => "a",
# "nest" => {
@rgarner
rgarner / csharp7-switch.cs
Created August 26, 2016 21:29 — forked from mythz/csharp7-switch.cs
Proposed pattern matching in C#
// From: https://blogs.msdn.microsoft.com/dotnet/2016/08/24/whats-new-in-csharp-7-0/
switch(shape)
{
case Circle c:
WriteLine($"circle with radius {c.Radius}");
break;
case Rectangle s when (s.Length == s.Height):
WriteLine($"{s.Length} x {s.Height} square");
break;