The Crystal programming language | http://crystal-lang.org | Fund Crystal's development: http://is.gd/X7PRtI | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/
MyModule
into Foo
, Foo.new.is_a? MyModule # => true
, but if you extend the module it affects the type of Foo.class
not the actual instance type
src/myproject/
, and in a MyProject
module. In src/myproject.cr
I basically just do require "./src/myproject/*
. Now I would like to add a "common.cr" file with common functionality between all the structs, implementing mostly class methods, and also available to users of the library. I can't seem to figure out how to get that to work.
nearly_equal?(x, y, rel_tol, abs_tol)
method I wrote yesterday. This would be used in the implementation of several of each of the structs' instance methods.
AlwaysInline
annotation was implied, or a way to opt in/out
undefined macro method 'Path#instance_vars'
confused me way longer than i wanna admit... it refers to Crystal::Macros::Path
and not Path
:P
macro derive_from(owner, *names)
\{% for name in names %}
\{% var = owner.resolve.instance_vars.find{ |v| v == name } %}
property \{{name}} : \{{var.type}}
\{% end %}
def initialize( \{{ names.map{ |n| "@#{n}".id }.join("").id }} )
end
\{% debug %}
end