Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAmy Kang
17,188 PointsUnexpected symbol '=>' in class, struct, or interface member declaration
Getting this error when I compile my code with mono on my local machine (Ubuntu).
namespace TreehouseDefense
{
class Invader
{
private readonly Path path;
private int pathStep = 0;
public MapLocation Location => this.path.GetLocationAt(this.pathStep);
public Invader(Path path)
{
this.path = path;
}
public void Move() => this.pathStep += 1;
}
}
2 Answers
Steven Parker
231,269 PointsExpression Bodied Members are a recent language addition.
Check your mono/mcs version number. I believe this feature was first available in version 3.8.
The current version is 4.4 — perhaps it's time for an upgrade?
Rikki MCguire
2,232 Pointsyou can also write it like this public void Move() { _pathStep += 1;}
Amy Kang
17,188 PointsAmy Kang
17,188 PointsYep turns out it was my version of C#. I have version 4.0. Just wrote it long form instead.