Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ポリモーフィズム #56

Open
marihachi opened this issue Feb 13, 2023 · 0 comments
Open

ポリモーフィズム #56

marihachi opened this issue Feb 13, 2023 · 0 comments
Labels

Comments

@marihachi
Copy link
Member

marihachi commented Feb 13, 2023

まずはどんな方法があるかを考えていく

関連技術

  • インターフェースとアップキャスト(C#など)
  • Rustのトレイト

オーバーロード

fn add(x: number, y: number): number {
  return x + y;
}
fn add(x: string, y: string): string {
  return concatStr(x, y);
}
var a: number = add(1, 2);
var b: string = add("hello", " world");
@marihachi marihachi changed the title 具体的な型をより抽象的な型としても扱えるように ポリモーフィズム Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant