Reputation: 33026
I think this code should be right. But it's not. Why?
export module Menu {
export class FileHandler {
var infoDisabled : boolean = false;
isInfoDisabled() : boolean {
return infoDisabled;
}
What do I have wrong in this? (I've tried a lot of variations, none worked.)
Upvotes: 1
Views: 3501
Reputation: 251242
Two quick changes... Mark the property private (or public if you like) and access it using this.
export class FileHandler {
private infoDisabled : boolean = false;
isInfoDisabled() : boolean {
return this.infoDisabled;
}
Upvotes: 3
Reputation: 5213
You were close. :)
export module Menu {
export class FileHandler {
infoDisabled : boolean = false;
isInfoDisabled() : boolean {
return this.infoDisabled;
}
}
}
You cannot define variables at the class level, only properties and methods. Accessing infoDisabled requires the 'this' keyword. And you were missing one or two closing braces. :)
Upvotes: 3