What is the best way to type cast os.date('%Y') return value as integer? #216
Answered
by
RaycatWhoDat
stefanos82
asked this question in
Q&A
-
I have attempted the following example without success: require 'os'
local year = (@int64)(os.date('%Y'))
print(year) What is the ideal way to cast a string to integer? |
Beta Was this translation helpful? Give feedback.
Answered by
RaycatWhoDat
May 27, 2023
Replies: 2 comments 6 replies
-
require 'os'
local year: int64 = tonumber(os.date('%Y'))
print(year) ? Also, you'll probably get a faster response in the Discord. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
stefanos82
-
@edubart based on the example above by @RayMPerry, if I don't set its type explicitly, why is it require 'os'
do
local year = tonumber(os.date('%Y'), 10)
print(year) -- 2023
##[[
print(string.format("year.type: %s", year.type)) -- year.type: nil
]]
end I have tried the same with I thought this was being applied: Am I doing something wrong? |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
?
Also, you'll probably get a faster response in the Discord.