Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Calling a function by argument type only

$
0
0

I have seen functions defined without argument values, just types for dispatch as so:

function foo(::Int, n)
  return Int(n)
end

First question: What is this type-only argument style called? I can’t seem to find its documentation.

Second question: Is there a way to call such a function without passing a value for the first argument? In principle, something like foo(::Int, 4) could be possible (but I’m not sure if it’s supported or considered somehow unjulian).

Thanks!

8 posts - 4 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795

Latest Images

Trending Articles



Latest Images