+1 @Tom Breloff .  
I was confused about this when starting out. Comparing   `for i in 1:3` vs 
 `for i = 1:3`, even though I regularly use matlab if you think about it 
for `i = 1:10` doesn't really make a lot of sense. It would be nice if it 
was just one way as opposed to the confusion about whether = or in should 
be used.

On Tuesday, October 27, 2015 at 10:26:44 AM UTC-4, Tom Breloff wrote:
>
> It's harmless, sure, but I would prefer that everyone uses "in" 
> exclusively so that there's one less thing to waste brainpower on.  You 
> don't say "for each x equals the range 1 to n", you say "for each x in the 
> range 1 to n".  I don't think "=" has a place here at all except to allow 
> copy/pasting of Matlab code (which creates other performance problems 
> anyways).
>
> On Tue, Oct 27, 2015 at 10:04 AM, Stefan Karpinski <[email protected] 
> <javascript:>> wrote:
>
>> My general approach is to only use = when the RHS is an explicit range, 
>> as in `for i = 1:n`. For everything else I use `for i in v`. I would be ok 
>> with dropping the = syntax at some point, but it seems pretty harmless to 
>> have it.
>>
>> On Tue, Oct 27, 2015 at 8:56 AM, FANG Colin <[email protected] 
>> <javascript:>> wrote:
>>
>>> Thank you. In that case I will happily stick with `in`.
>>>
>>>
>>> On Monday, October 26, 2015 at 8:43:22 PM UTC, Alireza Nejati wrote:
>>>>
>>>> There is no difference, as far as I know.
>>>>
>>>> '=' seems to be used more for explicit ranges (i = 1:5) and 'in' seems 
>>>> to be used more for variables (i in mylist). But using 'in' for everything 
>>>> is ok too.
>>>>
>>>> The '=' is there for familiarity with matlab. Remember that julia's 
>>>> syntax was in part designed to be familiar to matlab users.
>>>>
>>>> On Tuesday, October 27, 2015 at 8:26:07 AM UTC+13, FANG Colin wrote:
>>>>>
>>>>> Hi All
>>>>>
>>>>> I have got a stupid question:
>>>>>
>>>>> Are there any difference in "for i in 1:5" and "for i = 1:5"?
>>>>>
>>>>> Does the julia community prefer one to the other? I see use of both in 
>>>>> the documentations and source code.
>>>>>
>>>>> Personally I haven't seen much use of "for i = 1:5" in other 
>>>>> languages.
>>>>>
>>>>> Thanks.
>>>>>
>>>>
>>
>

Reply via email to