# A playful competition: who can define a method that invalidates the most code?

**URL:** <https://discourse.julialang.org/t/a-playful-competition-who-can-define-a-method-that-invalidates-the-most-code/47543>\
**Category:** Tooling\
**Tags:** competition\
**Created:** [September 30, 2020, 3:21pm UTC](https://discourse.julialang.org/t/a-playful-competition-who-can-define-a-method-that-invalidates-the-most-code/47543 "2020-09-30T15:21:54Z")\
**Posts on this page:** 1\
**Showing post:** 46

<div class="post-metadata">

**Author:** ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)\
**Post date:** [October 6, 2020, 6:28pm UTC](https://discourse.julialang.org/t/a-playful-competition-who-can-define-a-method-that-invalidates-the-most-code/47543/46 "2020-10-06T18:28:18Z")

</div>

Not as bad as the winning `convert` methods, but it’s also easy to rack up a lot of invalidations with constructors

```julia
julia> using SnoopCompileCore

julia> struct X <: Integer; i::Int; end

julia> invalidations = @snoopr (::Type{T})(x::X) where {T} = T(x.i);

julia> using SnoopCompile; length(uinvalidated(invalidations))
733

```

---

_[View the full topic](https://discourse.julialang.org/t/a-playful-competition-who-can-define-a-method-that-invalidates-the-most-code/47543)._
