I'm reading someone else's code that I got elsewhere online, this only a portion of it...
def EarnPerShareY = if isNaN(EarningsPerShareTTM())
then EarnPerShareY[1]
else EarningsPerShareTTM();
I'm don't code (much), so I'm having a hard time understanding what I am reading. I've been looking up the learning center for thinkscript.
Basically it reads like if EarningsPerShareTTM() is a number, then EarnPerShareY[1], if it is not a number else EarningsPerShareTTM().
At this point I'm still not understanding what it is that I'm reading. Or how the logic of the script works. Can someone be so kind to explain it to me?
def EarnPerShareY = if isNaN(EarningsPerShareTTM())
then EarnPerShareY[1]
else EarningsPerShareTTM();
I'm don't code (much), so I'm having a hard time understanding what I am reading. I've been looking up the learning center for thinkscript.
- def EarnPerShareY, defining a variable
- isNaN, this one returns true or false depending if the value is a number
- EarningsPerShareTTM(), this gives quarterly EPS for the trailing 12 months
- then EarnPerShareY[1], some sort of variable with an array being setup? I don't understand what is happening here.
- else EarningsPerShareTTM(), I'm not sure what this line is about either
Basically it reads like if EarningsPerShareTTM() is a number, then EarnPerShareY[1], if it is not a number else EarningsPerShareTTM().
At this point I'm still not understanding what it is that I'm reading. Or how the logic of the script works. Can someone be so kind to explain it to me?