The compiler, given the following code, tells me "Use of unassigned local variable 'x'." Any thoughts?
public delegate Y Function<X,Y>(X x);
public class Map<X,Y>
{
private Function<X,Y> F;
public Map(Function f)
{
F = f;
}
public Collection<Y> Over(Collection<X> xs){
List<Y> ys = new List<Y>();
foreach (X x in xs)
{
X x2 = x;//ys.Add(F(x));
}
return ys;
}
}
After fixing the obvious errors it compiles fine for me.
public delegate Y Function<X,Y>(X x);
public class Map<X,Y>
{
private Function<X,Y> F;
public Map(Function<X,Y> f)
{
F = f;
}
public ICollection<Y> Over(ICollection<X> xs){
List<Y> ys = new List<Y>();
foreach (X x in xs)
{
X x2 = x;//ys.Add(F(x));
}
return ys;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With