Page 1 of 1

love.audio.play(my_sound) vs my_sound:play()

Posted: Sat Jul 19, 2014 12:53 am
by sphyrth
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?

Re: love.audio.play(my_sound) vs my_sound:play()

Posted: Sat Jul 19, 2014 1:13 am
by veethree
Are there significant differences between them?
No.
Are they used according to coders' preferences, or are they used according to their purpose?
Coders preferences.
Are there reasons why one is superior to the other, or are they both valid to use at the same time?
Neither is superior, Both valid at the same time.

It's just a matter of preference, I personally prefer my_sound:play(), I find it more pleasing aesthetically.

Re: love.audio.play(my_sound) vs my_sound:play()

Posted: Mon Jul 21, 2014 6:08 am
by Positive07
text:len()
string.len(text)

Yeah the same

Re: love.audio.play(my_sound) vs my_sound:play()

Posted: Mon Jul 21, 2014 7:19 am
by slime
Positive07 wrote:text:len()
string.len(text)

Yeah the same
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.

Re: love.audio.play(my_sound) vs my_sound:play()

Posted: Mon Jul 21, 2014 8:00 am
by sphyrth
:awesome:
Thanks for the info guys. Now I can move on.

Re: love.audio.play(my_sound) vs my_sound:play()

Posted: Tue Jul 22, 2014 6:05 pm
by Positive07
slime wrote:
Positive07 wrote:text:len()
string.len(text)

Yeah the same
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.
I should have used byte hahaha yeah I commonly use the length operator it is shorter... didnt know it was preferred, is it faster?

Re: love.audio.play(my_sound) vs my_sound:play()

Posted: Thu Jul 24, 2014 6:31 am
by Xgoff
Positive07 wrote:
slime wrote:
Positive07 wrote:text:len()
string.len(text)

Yeah the same
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.
I should have used byte hahaha yeah I commonly use the length operator it is shorter... didnt know it was preferred, is it faster?
technically, yes, it is faster

but the real reason it's preferred is because they added specific syntax for it