Skip to content

Instantly share code, notes, and snippets.

@frodo821
Created January 15, 2018 06:14
Show Gist options
  • Save frodo821/c6a3863f0bbbdbdb8d89fb18d8955cd5 to your computer and use it in GitHub Desktop.
Save frodo821/c6a3863f0bbbdbdb8d89fb18d8955cd5 to your computer and use it in GitHub Desktop.
#-*-coding: utf-8;-*-
from overload import overload
@overload
def test(a: int, b: int):
print(a + b)
@overload
def test(a: str, b:str):
print("{} and {} was passed!".format(a,b))
@overload
def test(a: int):
print("Integer {}".format(a))
@overload
def test(a: str):
print("String {}".format(a))
test(1)
test("abc")
test(1, 2)
test("foo", "bar")
# output will:
#
# Integer 1
# String abc
# 3
# foo and bar was passed!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment