love.audio.play(my_sound)
my_sound:play()
-----
Alright, too much curiosity is striking me with these two codes:
Are there significant differences between them?
Are they used according to coders' preferences, or are they used according to their purpose?
Are there reasons why one is superior to the other, or are they both valid to use at the same time?
love.audio.play(my_sound) vs my_sound:play()
Re: love.audio.play(my_sound) vs my_sound:play()
No.Are there significant differences between them?
Coders preferences.Are they used according to coders' preferences, or are they used according to their purpose?
Neither is superior, Both valid at the same time.Are there reasons why one is superior to the other, or are they both valid to use at the same time?
It's just a matter of preference, I personally prefer my_sound:play(), I find it more pleasing aesthetically.
- Positive07
- Party member
- Posts: 1014
- Joined: Sun Aug 12, 2012 4:34 pm
- Location: Argentina
Re: love.audio.play(my_sound) vs my_sound:play()
text:len()
string.len(text)
Yeah the same
string.len(text)
Yeah the same
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
- slime
- Solid Snayke
- Posts: 3166
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: love.audio.play(my_sound) vs my_sound:play()
The length operator (#text) should probably be preferred for getting the length of a string - the official online edition of the Programming in Lua book was written for Lua 5.0 which didn't have the length operator, so it doesn't mention it unfortunately.Positive07 wrote:text:len()
string.len(text)
Yeah the same
Re: love.audio.play(my_sound) vs my_sound:play()
Thanks for the info guys. Now I can move on.
- Positive07
- Party member
- Posts: 1014
- Joined: Sun Aug 12, 2012 4:34 pm
- Location: Argentina
Re: love.audio.play(my_sound) vs my_sound:play()
I should have used byte hahaha yeah I commonly use the length operator it is shorter... didnt know it was preferred, is it faster?slime wrote:The length operator (#text) should probably be preferred for getting the length of a string - the official online edition of the Programming in Lua book was written for Lua 5.0 which didn't have the length operator, so it doesn't mention it unfortunately.Positive07 wrote:text:len()
string.len(text)
Yeah the same
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Re: love.audio.play(my_sound) vs my_sound:play()
technically, yes, it is fasterPositive07 wrote:I should have used byte hahaha yeah I commonly use the length operator it is shorter... didnt know it was preferred, is it faster?slime wrote:The length operator (#text) should probably be preferred for getting the length of a string - the official online edition of the Programming in Lua book was written for Lua 5.0 which didn't have the length operator, so it doesn't mention it unfortunately.Positive07 wrote:text:len()
string.len(text)
Yeah the same
but the real reason it's preferred is because they added specific syntax for it
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 2 guests