前面介紹了很多種制式的積木方塊,那積木可以自己做嗎? 當然可以
讓我們來看看要怎麼進行
enum MyEnum {
//% block="one"
One,
//% block="two"
Two
}
/**
* Custom blocks
*/
//% weight=100 color=#0fbc11 icon=""
namespace custom {
/**
* TODO: describe your function here
* @param n describe parameter here, eg: 5
* @param s describe parameter here, eg: "Hello"
* @param e describe parameter here
*/
//% block
export function foo(n: number, s: string, e: MyEnum): void {
// Add code here
basic.showString("Function foo called with n=" + n + ", s=" + s + ", e=" + e);
}
/**
* TODO: describe your function here
* @param value describe value here, eg: 5
*/
//% block
export function fib(value: number): number {
return value <= 1 ? value : fib(value - 1) + fib(value - 2);
}
}