Multiple dispatch is actually really well suited for this. The idiomatic
approach in Julia is quite similar to your c++ example, at least conceptually:
immutable Foo end
immutable Bar end
alg(::Type{Foo}) = println("I'm using foo")
alg(::Type{Bar}) = println("I'm using bar")
strategy = Foo #
Hi,
By exploring Julia I'm curios what would be a best way to implement
strategy design pattern in Julia. I'm posting a C++ example, for which I
would like to write equivalent in Julia.
Thanks.
#include
#include
#include
template
void foo_t(const T& t)
{
std::cout << "I'm using foo_t... \