1. Học hỏi
  2. /
  3. Khoa Học
  4. /
  5. Introduction to Julia

Connected

Bài tập

Multiple dispatch

Multiple dispatch is one of the unique features of Julia, and it will help you write really neat and efficient code. Earlier in this chapter, you wrote some code to check whether a variable had the correct type for a function. With multiple dispatch we can handle different input types more effectively.

In this exercise, you will write a function that uses multiple dispatch.

Hướng dẫn 1/2

undefined XP
    1
    2
  • Write a function named negative() which takes an argument named x which can be of any type and returns -x.