Forget what I've said. Apparently it is my constructor that isn't working
on variable. Sorry for the noise.
On Saturday, February 15, 2014 1:15:53 PM UTC+2, Johan Sigfrids wrote:
>
> Hmm. Or maybe neither work and the for loop is only hiding the error?
>
> On Saturday, February 15, 2014 1:11:36 PM UTC+2, Johan Sigfrids wrote:
>>
>> I've been playing with a Degree type in Julia, and have set it up so I
>> can use ° to construct Degrees:
>>
>> module Degrees
>>
>> export Degree, °
>>
>> immutable Degree{T<:Number} <:Number
>> d::T
>> end
>>
>> immutable DegreeSign end
>>
>> const ° = DegreeSign()
>>
>> *(num::Number, s::DegreeSign) = Degree(num)
>>
>> Base.show(io::IO, d::Degree) = print(io, "$(d.d)°")
>>
>> end
>>
>> I can successfully construct a array of Degrees with a for loop like so:
>>
>> for i in 1:10
>> i°
>> end
>>
>> But the same thing doesn't work in a comprehension:
>>
>> [ i° for i in 1:10]
>>
>> This leads to a error complaining that `i° not defined`. It sounds to me
>> like it is evaluating `i°` before i has a value assigned to it. What's
>> going on here?
>>
>