# \#methods

**URL:** https://discourse.julialang.org/tag/methods/1044.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [\[Documentation Incomplete Explanation?\] Methods Chapter - Redefining Methods](https://discourse.julialang.org/t/documentation-incomplete-explanation-methods-chapter-redefining-methods/135695)

<div class="topic-metadata">

**Author:** [@fincleah](https://discourse.julialang.org/u/fincleah)\
**Replies:** 4\
**Last updated:** [February 20, 2026, 11:04am UTC](https://discourse.julialang.org/t/documentation-incomplete-explanation-methods-chapter-redefining-methods/135695 "2026-02-20T11:04:06Z")

</div>

Hi - I’m currently reading the manual to learn Julia. I’ve spotted maybe an incomplete example in the Methods chapter on redefining methods. It seems to say that there are two definitions of the newfun() function, but …

---

## [\[Documentation Minor Typo?\] Parametric Methods - Statement Regarding Return Type Declarations](https://discourse.julialang.org/t/documentation-minor-typo-parametric-methods-statement-regarding-return-type-declarations/135694)

<div class="topic-metadata">

**Author:** [@fincleah](https://discourse.julialang.org/u/fincleah)\
**Replies:** 0\
**Last updated:** [February 16, 2026, 10:28pm UTC](https://discourse.julialang.org/t/documentation-minor-typo-parametric-methods-statement-regarding-return-type-declarations/135694 "2026-02-16T22:28:53Z")

</div>

Hi All, I’ve been reading through the manual in order to learn Julia, and I’m on the Methods chapter. However, I think I’ve spotted a typo? It’s a very minor thing - but I think the sentence is saying that the where st…

---

## [Method specificity/priority rules](https://discourse.julialang.org/t/method-specificity-priority-rules/132932)

<div class="topic-metadata">

**Author:** [@raman\_kumar](https://discourse.julialang.org/u/raman_kumar)\
**Replies:** 13\
**Last updated:** [January 6, 2026, 6:38pm UTC](https://discourse.julialang.org/t/method-specificity-priority-rules/132932 "2026-01-06T18:38:53Z")

</div>

Please explain methods priority or specificity in different cases. Where in Julia documentation is it explained? The following line and example in documentation are contradictory. The order in which the methods are def…

---

## [Hidden version of searchsortedfirst](https://discourse.julialang.org/t/hidden-version-of-searchsortedfirst/131776)

<div class="topic-metadata">

**Author:** [@alan](https://discourse.julialang.org/u/alan)\
**Replies:** 4\
**Last updated:** [August 23, 2025, 9:05pm UTC](https://discourse.julialang.org/t/hidden-version-of-searchsortedfirst/131776 "2025-08-23T21:05:09Z")

</div>

In the Julia source code, there is an undocumented version of searchsortedfirst: function searchsortedfirst(v::AbstractVector, x, lo::T, hi::T, o::Ordering)::keytype(v) where T\<:Integer I need a function like this, in …

---

## [How to get type stability across methods?](https://discourse.julialang.org/t/how-to-get-type-stability-across-methods/129046)

<div class="topic-metadata">

**Author:** [@akriegman](https://discourse.julialang.org/u/akriegman)\
**Replies:** 9\
**Last updated:** [May 16, 2025, 6:17am UTC](https://discourse.julialang.org/t/how-to-get-type-stability-across-methods/129046 "2025-05-16T06:17:11Z")

</div>

I have a program where I want to dynamically choose a function from a list and have the result be type stable. All the methods involved do return the same type, but it appears that past a certain number of methods the ty…

---

## [Calling module specific method with same type signature (AbstractFFT, FFTW, FFTA)](https://discourse.julialang.org/t/calling-module-specific-method-with-same-type-signature-abstractfft-fftw-ffta/128750)

<div class="topic-metadata">

**Author:** [@jtravs](https://discourse.julialang.org/u/jtravs)\
**Replies:** 1\
**Last updated:** [May 6, 2025, 2:59pm UTC](https://discourse.julialang.org/t/calling-module-specific-method-with-same-type-signature-abstractfft-fftw-ffta/128750 "2025-05-06T14:59:12Z")

</div>

Consider the following example. If I run using FFTA a = rand(ComplexF64, 128) p = FFTA.plan\_fft(a) typeof(p) I get FFTA.FFTAPlan\_cx{ComplexF64, 1} but if I run using FFTA, FFTW a = rand(ComplexF64, 128) p = FFTA.pl…

---

## [Adding method to function in macro](https://discourse.julialang.org/t/adding-method-to-function-in-macro/128613)

<div class="topic-metadata">

**Author:** [@PatrickHaecker](https://discourse.julialang.org/u/PatrickHaecker)\
**Replies:** 14\
**Last updated:** [May 4, 2025, 4:49am UTC](https://discourse.julialang.org/t/adding-method-to-function-in-macro/128613 "2025-05-04T04:49:53Z")

</div>

I have a package which defines a function and some methods for this function when the package gets loaded. In addition, the package defines a macro which returns an expression which defines additional methods to this fu…

---

## [\`methods\` and \`@which\` give different results](https://discourse.julialang.org/t/methods-and-which-give-different-results/127954)

<div class="topic-metadata">

**Author:** [@sadish-d](https://discourse.julialang.org/u/sadish-d)\
**Replies:** 7\
**Last updated:** [April 11, 2025, 5:46pm UTC](https://discourse.julialang.org/t/methods-and-which-give-different-results/127954 "2025-04-11T17:46:29Z")

</div>

I have: f(; x) = 0 and I do: f(x = 1) creating one specialized method (MethodInstance?) of f. I can see the specialized method with a @which: julia\> (@which f(x = 1)) |\> Base.specializations Base.MethodSpecializati…

---

## [Invoke previous method version with identical signature](https://discourse.julialang.org/t/invoke-previous-method-version-with-identical-signature/127757)

<div class="topic-metadata">

**Author:** [@Ouroboros42](https://discourse.julialang.org/u/Ouroboros42)\
**Replies:** 2\
**Last updated:** [April 6, 2025, 7:01pm UTC](https://discourse.julialang.org/t/invoke-previous-method-version-with-identical-signature/127757 "2025-04-06T19:01:56Z")

</div>

Very simple example: I have a function f with one method, I would like to redefine that method, but call the old implementation from inside the new one. invoke cannot do this for identical signatures. The following lead…

---

## [How to avoid code getting precompiled because it gets executed while the package is being defined?](https://discourse.julialang.org/t/how-to-avoid-code-getting-precompiled-because-it-gets-executed-while-the-package-is-being-defined/126890)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 1\
**Last updated:** [March 13, 2025, 2:12am UTC](https://discourse.julialang.org/t/how-to-avoid-code-getting-precompiled-because-it-gets-executed-while-the-package-is-being-defined/126890 "2025-03-13T02:12:17Z")

</div>

Often times I have some code in a package that executes only during precompilation, not at run time. AFAIK Julia saves the MethodInstances of all such compiled Methods into the precompilation files, for some reason. How …

---

## [Could type ambiguity based on \`Union\` of concrete types be eliminated?](https://discourse.julialang.org/t/could-type-ambiguity-based-on-union-of-concrete-types-be-eliminated/126221)

<div class="topic-metadata">

**Author:** [@frankwswang](https://discourse.julialang.org/u/frankwswang)\
**Replies:** 4\
**Last updated:** [March 4, 2025, 6:03pm UTC](https://discourse.julialang.org/t/could-type-ambiguity-based-on-union-of-concrete-types-be-eliminated/126221 "2025-03-04T18:03:47Z")

</div>

MWE: julia\> foo(::Union{Int, Float64}, ::AbstractArray, ::AbstractArray) = 1 foo (generic function with 1 method) julia\> foo(::Int, ::Any, ::Any) = 2 foo (generic function with 2 methods) julia\> foo(1, \[1\], \[1\]) ERROR…

---

## [Incorrect \`method overwritten\` warning with optional kwargs..?](https://discourse.julialang.org/t/incorrect-method-overwritten-warning-with-optional-kwargs/120714)

<div class="topic-metadata">

**Author:** [@iago-lito](https://discourse.julialang.org/u/iago-lito)\
**Replies:** 4\
**Last updated:** [September 30, 2024, 2:56pm UTC](https://discourse.julialang.org/t/incorrect-method-overwritten-warning-with-optional-kwargs/120714 "2024-09-30T14:56:27Z")

</div>

My package exposes this caller method, whose behaviour may be controlled by consumers provided they specialize f: TestPkg/src/TestPkg.jl module TestPkg # Entry point for users. caller(a) = f(a; b = 1) export caller #…

---

## [Getting the parametric constructors from \`methods\`](https://discourse.julialang.org/t/getting-the-parametric-constructors-from-methods/96632)

<div class="topic-metadata">

**Author:** [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Replies:** 2\
**Last updated:** [September 29, 2024, 1:42am UTC](https://discourse.julialang.org/t/getting-the-parametric-constructors-from-methods/96632 "2024-09-29T01:42:58Z")

</div>

If I call methods(Dict), it just returns the “non-parametric constructors”: julia\> methods(Dict) # 5 methods for type constructor: \[1\] Dict() in Base at dict.jl:118 \[2\] Dict(ps::Pair{K, V}...) where {K, V} in Base at di…

---

## [Implicit numerical method using NLsolve.jl](https://discourse.julialang.org/t/implicit-numerical-method-using-nlsolve-jl/118525)

<div class="topic-metadata">

**Author:** [@khaledharizb](https://discourse.julialang.org/u/khaledharizb)\
**Replies:** 3\
**Last updated:** [August 23, 2024, 11:13am UTC](https://discourse.julialang.org/t/implicit-numerical-method-using-nlsolve-jl/118525 "2024-08-23T11:13:33Z")

</div>

I would like to implement Lobatto IIIA-IIIB which is an implicit method. To do so, a non-linear equations need to be solved. Then I used NLsolve.jl for my problem using NLsolve function NuMethod(fV::Function,fT::Func…

---

## [Method for \`Base.length\` on a \`const\` type alias crashes julia](https://discourse.julialang.org/t/method-for-base-length-on-a-const-type-alias-crashes-julia/118169)

<div class="topic-metadata">

**Author:** [@kunzaatko](https://discourse.julialang.org/u/kunzaatko)\
**Replies:** 7\
**Last updated:** [August 15, 2024, 8:36am UTC](https://discourse.julialang.org/t/method-for-base-length-on-a-const-type-alias-crashes-julia/118169 "2024-08-15T08:36:05Z")

</div>

Julia is crashing when I try to define a Base.length method on a const type alias. julia\> import Base: length julia\> const A{N} = NTuple{N, Int64} Tuple{Vararg{Int64, N}} where N julia\> length(a::A) = prod(a) After …

---

## [Vector{NamedTuple} vs Vector{@NamedTuple}?](https://discourse.julialang.org/t/vector-namedtuple-vs-vector-namedtuple/118111)

<div class="topic-metadata">

**Author:** [@Nathan\_Boyer](https://discourse.julialang.org/u/Nathan_Boyer)\
**Replies:** 4\
**Last updated:** [August 13, 2024, 5:45am UTC](https://discourse.julialang.org/t/vector-namedtuple-vs-vector-namedtuple/118111 "2024-08-13T05:45:12Z")

</div>

How can I open my function method to work on all NamedTuples collected into a Vector? I don’t understand why this isn’t working. function multicall(f::Function, user\_inputs::Vector{NamedTuple}; kwargs...) out = \[\] …

---

## [\[Ann\] MethodInspector.jl: Package to inspect method APIs](https://discourse.julialang.org/t/ann-methodinspector-jl-package-to-inspect-method-apis/116893)

<div class="topic-metadata">

**Author:** [@bluesmoon](https://discourse.julialang.org/u/bluesmoon)\
**Replies:** 0\
**Last updated:** [July 11, 2024, 8:31am UTC](https://discourse.julialang.org/t/ann-methodinspector-jl-package-to-inspect-method-apis/116893 "2024-07-11T08:31:33Z")

</div>

Bit late announcing this, but reminded by Michael Tiemann’s talk at JuliaCon. Announcing MethodInspector.jl Code at: GitHub - bluesmoon/MethodInspector.jl: Julia package to inspect the names and types of method argumen…

---

## [Should Any have an identity constructor method?](https://discourse.julialang.org/t/should-any-have-an-identity-constructor-method/109500)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 10\
**Last updated:** [January 31, 2024, 10:31am UTC](https://discourse.julialang.org/t/should-any-have-an-identity-constructor-method/109500 "2024-01-31T10:31:00Z")

</div>

Many non-concrete types have constructors, for example we have AbstractFloat(0.3) == 0.3 and Union{Int,Float64}(0.3) == 0.3. Should we also have a method like Any(x) = x? Then we would have map(Any, \[3,4,5\]) == map(ident…

---

## [How to call the original Base.show function extended in DataFrames.jl while overriding it?](https://discourse.julialang.org/t/how-to-call-the-original-base-show-function-extended-in-dataframes-jl-while-overriding-it/104437)

<div class="topic-metadata">

**Author:** [@raythurnevoid](https://discourse.julialang.org/u/raythurnevoid)\
**Replies:** 3\
**Last updated:** [October 1, 2023, 3:52am UTC](https://discourse.julialang.org/t/how-to-call-the-original-base-show-function-extended-in-dataframes-jl-while-overriding-it/104437 "2023-10-01T03:52:55Z")

</div>

I’m using the DataFrames.jl package and I want to change the default behavior of show(), I want to print all the rows and columns without passing additional arguments because I want it to work seamlessly while calling di…

---

## [Vector with negative indices extending getindex](https://discourse.julialang.org/t/vector-with-negative-indices-extending-getindex/104286)

<div class="topic-metadata">

**Author:** [@gvdr](https://discourse.julialang.org/u/gvdr)\
**Replies:** 4\
**Last updated:** [September 27, 2023, 12:19am UTC](https://discourse.julialang.org/t/vector-with-negative-indices-extending-getindex/104286 "2023-09-27T00:19:00Z")

</div>

Hello. I’m trying to extend the method(s) for get index so to have the ability of accessing a numeric vector, Vector{T} where T\<:Number, at a negative (or zero) index and get zero(T). The intended behaviour is something…

---

## [Good template for defining a custom type with an addition method](https://discourse.julialang.org/t/good-template-for-defining-a-custom-type-with-an-addition-method/101725)

<div class="topic-metadata">

**Author:** [@pierre-haessig](https://discourse.julialang.org/u/pierre-haessig)\
**Replies:** 5\
**Last updated:** [July 20, 2023, 3:22pm UTC](https://discourse.julialang.org/t/good-template-for-defining-a-custom-type-with-an-addition-method/101725 "2023-07-20T15:22:53Z")

</div>

Hello, I’m implementing for the first time a custom type with a custom addition method (i.e. the + operator). Unless I missed something in the manual, I didn’t find a paragraph focused on the topic. After several itera…

---

## [Name this method extension technique, piracy evasion](https://discourse.julialang.org/t/name-this-method-extension-technique-piracy-evasion/101099)

<div class="topic-metadata">

**Author:** [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Replies:** 21\
**Last updated:** [July 4, 2023, 7:42am UTC](https://discourse.julialang.org/t/name-this-method-extension-technique-piracy-evasion/101099 "2023-07-04T07:42:40Z")

</div>

Let’s say I want to change how Base.write works with a Base type, NTuple{N,UInt8} from a package. Currently, writing NTuple via Base.write errors. julia\> iob = IOBuffer() IOBuffer(data=UInt8\[...\], readable=true, writab…

---

## [Computationally efficient image filtering](https://discourse.julialang.org/t/computationally-efficient-image-filtering/98889)

<div class="topic-metadata">

**Author:** [@donkeysaddle](https://discourse.julialang.org/u/donkeysaddle)\
**Replies:** 3\
**Last updated:** [May 16, 2023, 12:49pm UTC](https://discourse.julialang.org/t/computationally-efficient-image-filtering/98889 "2023-05-16T12:49:16Z")

</div>

I would like to filter hundreds of thousands of small images (say 35x35), using 5x5 kernels (that do not factor). I only want the “good data,” meaning the 31x31 filtered image that comes from correlating the filter at ea…

---

## [Method to Dict](https://discourse.julialang.org/t/method-to-dict/95840)

<div class="topic-metadata">

**Author:** [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Replies:** 2\
**Last updated:** [March 10, 2023, 10:34am UTC](https://discourse.julialang.org/t/method-to-dict/95840 "2023-03-10T10:34:08Z")

</div>

Is it possible to convert a method to a dictionary (or similar structure) with entries: Argument\_Name =\> Argument\_Type

---

## [Disappearing methods from loaded libraries, seemingly iff \`using PreallocationTools\`](https://discourse.julialang.org/t/disappearing-methods-from-loaded-libraries-seemingly-iff-using-preallocationtools/93496)

<div class="topic-metadata">

**Author:** [@joaovgranja](https://discourse.julialang.org/u/joaovgranja)\
**Replies:** 6\
**Last updated:** [January 25, 2023, 4:32pm UTC](https://discourse.julialang.org/t/disappearing-methods-from-loaded-libraries-seemingly-iff-using-preallocationtools/93496 "2023-01-25T16:32:50Z")

</div>

I have a weird issue that I am unable to reproduce in a MWE. It happens in the context of a reasonably large project. Some methods are not available despite their libraries being loaded. For instance: MethodError: no m…

---

## [Define new method in package – what is the syntax for importing the generic?](https://discourse.julialang.org/t/define-new-method-in-package-what-is-the-syntax-for-importing-the-generic/90622)

<div class="topic-metadata">

**Author:** [@baptiste](https://discourse.julialang.org/u/baptiste)\
**Replies:** 7\
**Last updated:** [November 23, 2022, 2:53am UTC](https://discourse.julialang.org/t/define-new-method-in-package-what-is-the-syntax-for-importing-the-generic/90622 "2022-11-23T02:53:36Z")

</div>

I’m using various functions from Rotations in my own package, and at some point decided to create a new method for convenience, # splatted version RotZYZ(v::SVector) = RotZYZ(v...) but I seem to get in trouble with thi…

---

## [Find where a specific method gets called](https://discourse.julialang.org/t/find-where-a-specific-method-gets-called/89068)

<div class="topic-metadata">

**Author:** [@jlbosse](https://discourse.julialang.org/u/jlbosse)\
**Replies:** 2\
**Last updated:** [October 21, 2022, 3:09pm UTC](https://discourse.julialang.org/t/find-where-a-specific-method-gets-called/89068 "2022-10-21T15:09:07Z")

</div>

Is there a way to find all places in my code base where a specific method (not function!) gets called (or may get called)? The method in question for me is Base.\*, so greping for \* over the whole code base produces way t…

---

## [Base.methods matches subtypes and supertypes](https://discourse.julialang.org/t/base-methods-matches-subtypes-and-supertypes/83525)

<div class="topic-metadata">

**Author:** [@tictaccat](https://discourse.julialang.org/u/tictaccat)\
**Replies:** 0\
**Last updated:** [June 29, 2022, 4:21pm UTC](https://discourse.julialang.org/t/base-methods-matches-subtypes-and-supertypes/83525 "2022-06-29T16:21:05Z")

</div>

Base.methods seems to return both subtypes and supertypes: julia\> f(x::Integer) = 3 f (generic function with 1 method) julia\> methods(f, (Number,)) # 1 method for generic function "f": \[1\] f(x::Integer) in Main at REPL…

---

## [How to add methods to a function](https://discourse.julialang.org/t/how-to-add-methods-to-a-function/81730)

<div class="topic-metadata">

**Author:** [@rocco\_sprmnt21](https://discourse.julialang.org/u/rocco_sprmnt21)\
**Replies:** 2\
**Last updated:** [May 26, 2022, 4:14pm UTC](https://discourse.julialang.org/t/how-to-add-methods-to-a-function/81730 "2022-05-26T16:14:27Z")

</div>

Suppose it has the task of writing a function that splits a given string at the points where there is a character change from one from to another to set. To delimit the context, suppose that the from and the to can be d…
