Created
January 15, 2018 06:14
-
-
Save frodo821/c6a3863f0bbbdbdb8d89fb18d8955cd5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-*-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