Crystal 0.20.1 released!
Crystal 0.20.1 has been released!
As any release it includes numerous bugfixes, cool features and performance improvements - in 75 commits since 0.20.0.
Exciting Changes
Section titled Exciting Changes- pand- ppnow use pretty printing.
- finishedmacro hook was added. It places it’s contents at the end of the program when all other types and methods are known.
class MyModel
  MAPPING = {
    id: Int32
  }
  macro extra_attributes(**values){% for key, value in values %}{% MAPPING[key] = value %}{% end %}
  end
  macro finished
    JSON.mapping({{MAPPING}})
  end
end
class MyModel
  extra_attributes name: String, foo: Bool
end
## JSON mapping will have attribute id, name and foo.
- Local variables can now have type restrictions.
- method_missinghook can now define a method, this allows it to control whether it captures a block (see PR #3610)
class Foo
  def add(method, &block : -> U) forall U
    puts "added #{method} #{block}"
  end
  macro method_missing(call)
    def {{call.name}}(&block : -> U) forall U
      add({{call.name.stringify}}, &block)
    end
  end
end
Foo.new.foo { 1 } # => added foo #<Proc(Int32):0x1063173a0>
Foo.new.bar { 2 } # => added bar #<Proc(Int32):0x1063173b0>
Other Breaking Changes
Section titled Other Breaking Changes- (breaking change) Set#mergeas renamed toSet#merge!
- (breaking change) Slice.new(size)no longer works with non primitive integers and floats
- (breaking change) The macro method argifywas renamed tosplat
Thanks to everyone who supported this release through contributions, reviews and suggestions.
