diff --git a/src/lazybroadcasting.jl b/src/lazybroadcasting.jl index 09b0ab6..afe6bc7 100644 --- a/src/lazybroadcasting.jl +++ b/src/lazybroadcasting.jl @@ -88,7 +88,10 @@ Broadcasted(A::SubArray{<:Any,N,<:BroadcastArray}) where N = broadcasted(A)::Bro axes(A::BroadcastArray) = axes(broadcasted(A)) size(A::BroadcastArray) = map(length, axes(A)) -last(A::BroadcastArray) = A.f(last.(A.args)...) +_broadcast_last(a) = a +_broadcast_last(a::AbstractArray) = last(a) +_broadcast_last(a::Ref) = a[] +last(A::BroadcastArray) = A.f(_broadcast_last.(A.args)...) @propagate_inbounds getindex(A::BroadcastArray{T,N}, kj::Vararg{Int,N}) where {T,N} = convert(T,broadcasted(A)[kj...])::T