打字稿接口不能分配?

时间:2019-11-22 09:38:01

标签: typescript

  

对不起,

我最近看到了这样的一段代码。

interface BaseTack{
    ():String
}

上面的代码是有效的声明。

但是我不知道如何分配它!

请帮我 。谢谢

1 个答案:

答案 0 :(得分:0)

一个例子是#include<stdio.h> int main(){ char str[8], conv_str[8],c; int i,val,ans = 0; while(1){ printf("Enter 8 values(0-9) :\n"); scanf("%[^\n]", str); // Scan values to str untill \n for(i = 0;i < 8;i++){ val = str[i]-48; //convert from asci to int ans += val; } while(ans > 9){ // itoa convert int to string, str(the input) is the buffer and 10 is the base itoa(ans,conv_str,10); ans = (conv_str[0]-48) + (conv_str[1]-48) ; } printf("the digit is: %d", ans); printf("\ncontinue? (y/n)\n"); scanf("%s", &c); if (c == 'n') break; memset(str, 0, sizeof(str)); } return 0; }

实际上,它是一个不接受任何参数并返回let a: BaseTack = () => '123';类型值的函数。

参考文献:

相关问题