So I was trying to do a bit of programming problems on LeetCode and I saw a method of class declaration that I'm not so familiar with. This was how it was:
class Solution:
def romanToInt(self, s: str) -> int:
And what I'm used to is something more like:
class Solution:
def romanToInt(self, s):
Is there a difference between the two?
CodePudding user response:
It is a type annotation that has no runtime significance (in the absence of other libraries like Pydantic), but allows for some static type checking.
In this case, it simply means that the type of s
is a string, and that the method returns an int