This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Couldn't wrap my head around the proper use of List.fold or List.reduce, especially | |
// with the type system getting in the way. But here is a proper implementation that | |
// is recursive. | |
// Dart, like many other languages does not handle recursion very well (it doesn't | |
// have "Tail Call Optimization") so it's not recommended to use this if we recurse | |
// many times. It's hard to put an exact number to "many" though. In the dart VM it may | |
// be 15 times, or a thousand, and in JS I would bet it's 15. | |
// In any case, this extension method is syntaxic sugar for code like m['x']['y']['z'] | |
// which is 3 recursions, so I doubt we'll ever get to even 10 recursions :) | |
extension NavigableMap on Map<String, dynamic> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:test/test.dart'; | |
import 'package:mocktail/mocktail.dart'; | |
class Demo { | |
void doSomething(int i) { | |
i + i; | |
} | |
} | |
class DemoDouble extends Mock implements Demo {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I haven't actually written this controller yet, I'm adding one for illustration purposes. | |
defmodule Controller do | |
def list_products(connection, _params) do | |
products = connection.private.products_gateway.all() # no better way to inject stuff into a controller in elixir/phoenix :( | |
purchasable_products = Usecases.Shopper.ListProducts.list_products(products, Timex.now()) | |
send_resp(connection, 200, purchasable_products) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module MouseParticle where | |
import Graphics.Element exposing (..) | |
import Graphics.Collage exposing (..) | |
import Color exposing (..) | |
import Mouse | |
import Window | |
import Time | |
------------------------------------------------------ MODEL |