Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fish: Iterate over an array/list

Tags:

fish

How can you do an array literal? I tried:

for x in (635 35710 653 30420 29835 35004)                                                                       
   echo $x
end
like image 722
Justin Thomas Avatar asked Apr 01 '16 17:04

Justin Thomas


1 Answers

It's much simpler than you tried: for x in 635 35710 653 will work.

Think of for as another command that receives arguments, and arrays always expand each element to one argument - so just passing it like that will have the same effect as a (theoretical) more specialized array literal would.

like image 103
faho Avatar answered Nov 19 '22 19:11

faho