How is the isPrime() method called without an object? ex) pd.isPrime()
Hello @webplayer09172, welcome to the forums! The reason you can call
isPrime() within the
onlyPrimes() function is that they’re two (non-static) methods in the same class. If two methods are in the same class, and don’t have a difference in being static/non-static, then you can call them without creating an instance of the class.
Thank you sm for the explanation!