Re: Object to Atom

new topic     » goto parent     » topic index » view thread      » older message » newer message
DerekParnell said...
evanmars said...
object s = {2} 
atom my_atom 
 
if sequence(s) then 
	if length(s) = 1 then 
		my_atom = s[1] 
	end if 
end if 
 
? my_atom 

This is not very robust coding. If 's' is not a sequence or has a length other than 1, then 'my_atom' will not have been assigned anything, so it may crash the program later when you try to use it for anything.

True. I would normally have done something like:

atom my_atom = -1  --or atom my_atom = 0 

when declaring it.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu