On 11/09/18 12:50, ToddAndMargo wrote: > On 09/11/2018 03:09 AM, ToddAndMargo wrote: >> multi method contains(Str:D: Cool:D $needle, Int(Cool:D) $pos) > > What the heck (not my exact word) is "multi method"? > > What is wrong with calling it a "function"?
Multi Methods are methods that do "multiple dispatch", which means more or less "there are different candidates that can be called, and it depends on the arguments you pass. They are matched against the signatures of the candidates and the most appropriate one is called for you". Here's an example: class TestClass { multi method test-method(Str $input) { say "this version of test-method is for strings"; } multi method test-method(Int $input) { say "this version of test-method is for integers" } } my $tc = TestClass.new; $tc.test-method("hello"); $tc.test-method(1234); So you have the same name, but multiple candidates that have different signatures. Does that help? - Timo