Actually, LINQPad is not the culprit here. This is because of an optimization in Enumerable.Cast
:
public static IEnumerable<TResult> Cast<TResult>(this IEnumerable source) {
IEnumerable<TResult> typedSource = source as IEnumerable<TResult>;
if (typedSource != null) return typedSource;
if (source == null) throw Error.ArgumentNull("source");
return CastIterator<TResult>(source);
}
As you can see, if source
implements IEnumerable<TResult>
, then Cast
just returns the source unchanged. In this case, source
is of type Option[]
, which happens to implement IEnumerable<int>
, so Cast
returns an array of Option
, and LINQPad dumps it.
I must admit that it came as a surprise that Option[]
can be cast to IEnumerable<int>
, but it seems to be the case...