Coffeescript how to unpack as "tuples" in python

I am new to coffeescript. Is there any way that these three lines set the rotation and do the same thing as you would do in python, unpacking a tuple?

@cosines = [0,1,0] @branch.rotation.x = Math.asin(@cosines.x) @branch.rotation.y = Math.asin(@cosines.y) @branch.rotation.z = Math.asin(@cosines.z) 
+6
source share
1 answer

This is the best code I could come up with.

 @cosines = [0,1,0] rot = @branch.rotation [rot.x, rot.y, rot.z] = [Math.asin(c) for c in @cosines] 

Unpacking destructuring is the same as in Python, but with square brackets.

+7
source

Source: https://habr.com/ru/post/971717/


All Articles