Информация об изменениях

Сообщение Re[15]: А что мешает заменить JS? от 18.03.2017 11:07

Изменено 18.03.2017 11:59 Serginio1

Re[15]: А что мешает заменить JS?
Здравствуйте, vdimas, Вы писали:
V>В C# 6.0 тоже есть.

И вообще, Dart имеет мейнстримовый сишный синтаксис:

class User {
    num id;
    string name;

    User(this.id, this.name);

    string getInfo() {
        return "id: $id name: $name";
    }
}


А вот как на TS

class User {
    User(public id:number, name:string);

    string getInfo() {
        return `id: ${this.id} name: ${this.name}`;
    }
}


По мне так у TS лучше

Да конечно this напрягает. Возможно в будущих версиях от него избавятся.

А вообще почитай на досуге

TypeScript Basic Types

You can also use template strings, which can span multiple lines and have embedded expressions. These strings are surrounded by the backtick/backquote (`) character, and embedded expressions are of the form ${ expr }.

let fullName: string = `Bob Bobbington`;
let age: number = 37;
let sentence: string = `Hello, my name is ${ fullName }.

I'll be ${ age + 1 } years old next month.`
Re[15]: А что мешает заменить JS?
Здравствуйте, vdimas, Вы писали:
V>В C# 6.0 тоже есть.

И вообще, Dart имеет мейнстримовый сишный синтаксис:

class User {
    num id;
    string name;

    User(this.id, this.name);

    string getInfo() {
        return "id: $id name: $name";
    }
}


А вот как на TS

class User {
    User(public id:number, private name:string);

    string getInfo() {
        return `id: ${this.id} name: ${this.name}`;
    }
}


По мне так у TS лучше

Да конечно this напрягает. Возможно в будущих версиях от него избавятся.

А вообще почитай на досуге

TypeScript Basic Types

You can also use template strings, which can span multiple lines and have embedded expressions. These strings are surrounded by the backtick/backquote (`) character, and embedded expressions are of the form ${ expr }.

let fullName: string = `Bob Bobbington`;
let age: number = 37;
let sentence: string = `Hello, my name is ${ fullName }.

I'll be ${ age + 1 } years old next month.`