๋ถ๋ฅ ์ ์ฒด๋ณด๊ธฐ
![[ํ์
์คํฌ๋ฆฝํธ] ํ์ ๋ ๋คํ์ฑ, ํ์
์คํฌ๋ฆฝํธ ํ๋ก๊ทธ๋๋ฐ ์ด์งํธ๋ฆฌ ์์ ๋ถ์](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FmXYUv%2FbtrAs93CbmR%2FzntWnIswb99DzDk3EuhDSk%2Fimg.png)
[ํ์ ์คํฌ๋ฆฝํธ] ํ์ ๋ ๋คํ์ฑ, ํ์ ์คํฌ๋ฆฝํธ ํ๋ก๊ทธ๋๋ฐ ์ด์งํธ๋ฆฌ ์์ ๋ถ์
๋ณธ ํฌ์คํ ์์ ๋ฏธ๋ฆฌ๋ณด๊ธฐ 1. ํ์ ์คํฌ๋ฆฝํธ ํ๋ก๊ทธ๋๋ฐ ์์ ๋ด๊ฐ ํ์ด๋ณธ ๊ฒ(ํ ํฌ์ธํธ ๋ฏธ์ค, ์์ง๋ ์์ฑ์์ ํ์ดํ ํจ์ ๋ฐ์๋ค์ด๋๊ฒ ์ด์...) type TreeNode = { value: string; }; type LeafNode = TreeNode & { isLeaf: true; }; type InnerNode = TreeNode & { children: [TreeNode] | [TreeNode, TreeNode]; }; let a: TreeNode = { value: "a" }; //ํต๊ณผ let b: LeafNode = { value: "b", isLeaf: true }; //ํต๊ณผ let c: InnerNode = { value: "c", children: [b] }; //ํต๊ณผ let a1 = ..
![[ํ์
์คํฌ๋ฆฝํธ] ํ์
๋ณ์นญ ์ธํฐ์น์
์ ์ํ ํ์ฅ](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FP5Fp5%2FbtrAumukb81%2FAThIZnKBvYKCcT4khOyGtK%2Fimg.png)
[ํ์ ์คํฌ๋ฆฝํธ] ํ์ ๋ณ์นญ ์ธํฐ์น์ ์ ์ํ ํ์ฅ
์์ ๊ฐ์ด ์ธ๊ฐ์ ํ์ ๋ณ์นญ์ ๋์๋ค. ์ด๋ฅผ ํ ๋๋ก ์ฌ๋ฌ๊ฐ์ง ์คํ์ ํด๋ณผ ๊ฒ์ด๋ค. ํ์ ๋ณ์นญ์ extends๋ผ๋ ๋ช ๋ น์ด๊ฐ ์๊ณ ์ธํฐ์น์ (&)๋ฅผ ์ด์ฉํด ํ์ฅํ๋ค. type TreeNode = { value: string; }; type LeafNode = TreeNode & { isLeaf: true; }; type InnerNode = TreeNode & { children: [TreeNode] | [TreeNode, TreeNode]; }; 1. let a: TreeNode = { value: "a" }; //ํต๊ณผ let a1: TreeNode = { value: "a" , isLeaf: true}; ~~~~~~~~~~~~~ 2. let b: LeafNode = { value: "b", isLeaf: t..
[ํ์ ์คํฌ๋ฆฝํธ] ์ ๋ค๋ฆญ ํ์ ๋ณ์นญ
์๋ ์คํ์ผ๋ค๋ ์ ๋ค๋ฆญ ํ์ ๋ณ์นญ์ด๋ค. //์ฝ๊ธฐ ์ ์ฉ ๋ฐฐ์ด๊ณผ ํํ ๋ง๋๋ ์ฌ๋ฌ๊ฐ์ง ์ ์ธ ๋ฐฉ๋ฒ type A = readonly string[]; //readonly string[] type B = ReadonlyArray;//readonly string[] type C = Readonly; //readonly string[] type D = readonly [number,string]; //readonly [number,string] type E = Readonly;//readonly [number,string] ๊ฐ๋จํ ์๋ฅผ ํตํด ํ์ ๋ณ์นญ์์ ์ ๋ค๋ฆญ์ ํ์ฉํ๋ ๋ฐฉ๋ฒ์ ๋ ์์ธํ ์ดํด๋ณด์. (์ฐธ๊ณ ๋ก ์ด ์์ ์ ์ ts์์ DOM์ ๋ถ๋ฅด๊ธฐ ์ํด tsconfig.json์ lib ์ต์ ํ์ ์คํฌ๋ฆฝํธ๊ฐ ๋น๋ ๋ ..
![[ํ์
์คํฌ๋ฆฝํธ] ์ ๋ค๋ฆญ ํ์
๋ช
์ ์ฃผ์์ฌํญ](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FcKwpG1%2FbtrAqT7ivBF%2F6UCeFg1kK6YzrW8krKS6vk%2Fimg.png)
[ํ์ ์คํฌ๋ฆฝํธ] ์ ๋ค๋ฆญ ํ์ ๋ช ์ ์ฃผ์์ฌํญ
1. ์ ๋ค๋ฆญ ํ์ ๋ช ์ ์ฃผ์์ฌํญ ์ ๋ค๋ฆญ์ ํ์ ์ ๋ช ์ํ ๋๋ ๋ชจ๋ ํ์ํ ์ ๋ค๋ฆญ ํ์ ์ ๋ช ์ํ๊ฑฐ๋ ๋ฐ๋๋ก ์๋ฌด ๊ฒ๋ ๋ช ์ํด์๋ ์ ๋๋ค. ์ฆ, ์ด๋ ๊ฒ ์ฐ๊ฑฐ๋ ( ํ์ ๋ช ์) function map(array: T[], f: (item: T) => U): U[] { let result = []; for (let i = 0; i _ === "a")); //[ false, false, true ] ์ด๋ ๊ฒ ์จ์ผ ํ๋ค. (ํ์ ์ถ๋ก ) function map(array: T[], f: (item: T) => U): U..
[ํ์ ์คํฌ๋ฆฝํธ ๊ณตํ] User-Defined Type Guards
TypeScript: Documentation - Advanced Types (typescriptlang.org) Documentation - Advanced Types Advanced concepts around types in TypeScript www.typescriptlang.org User-Defined Type Guards It would be much better if once we performed the check, we could know the type of pet within each branch. It just so happens that TypeScript has something called a type guard. A type guard is some expression th..
![[์๋ฐ์ ์ ์] Hello Java & Eclipse ๋จ์ถํค](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FwYp5f%2FbtrAqIjY4IF%2FmPHiKXQ9AK1au5fVkokwT0%2Fimg.png)
[์๋ฐ์ ์ ์] Hello Java & Eclipse ๋จ์ถํค
์๋ก์ด ํด๋์ค๋ฅผ ๋ง๋๋ ค๋ฉด CTRL + n ํด๋์ค๋ช ์ฐพ๊ธฐ ctrl + SHIFT + R main ์ ์น๊ณ CTRL + SPACE : ๋ฉ์ธ ๋ฉ์๋ ์๋ ์์ฑ sysout์ ์น๊ณ CTRL + SPACE ์ ๋๋ฅด๋ฉด {System.out.printIn()}์ผ๋ก ์๋ ํ์ฅ https://youtu.be/E8fTLFuc7X4 CMD์ฐฝ์์ C:\jdk11\work>javac Helllo.java C:\jdk11\work>java Hello Hello, World https://youtu.be/emllFzqD1-0 ์ดํด๋ฆฝ์ค๋ ๊ธฐ๋ณธ์ ๊ทธ์ฌ ์์ค ํ์ผ๊ณผ ํด๋์ค ํ์ผ์ ๋ณ๋์ ํด๋์ ๋ด์์ ๊ด๋ฆฌํ๋ค. ํนํ .์ผ๋ก ์์ํ๋ ํ์ผ๋ค์ ์ดํด๋ฆฝ์ค๊ฐ ์๋์ผ๋ก ์์ฑํด์ ๋ง๋ ๊ด๋ จ ํ์ผ๋ค์ด๋ฏ๋ก ๊ฑด๋ค์ง ์๋ ๊ฒ์ด ์ข๋ค.
![[ํ์
์คํฌ๋ฆฝํธ] ์ ๋ค๋ฆญ ํด๋์ค](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FcgAgwL%2FbtrArHRUrjN%2FVak3a5ahcEj2uuEAso4pZ1%2Fimg.png)
[ํ์ ์คํฌ๋ฆฝํธ] ์ ๋ค๋ฆญ ํด๋์ค
//๋ค๋ฅธ ํ์ ์ผ๋ก ์ธ ์ ์๊ฒ ๋ฐ๊พธ๊ธฐ //either: a or b interface Either { left: () => T; right: () => U; } class SimpleEither implements Either { constructor(private leftValue: T, private rightValue: U) {} left(): T { return this.leftValue; } right(): U { return this.rightValue; } } const either = new SimpleEither(4, { name: "ํ๊ธธ๋", age: 18 }); console.log(either.left()); //4 console.log(either.right()); //ํ๊ธธ๋โ /..
[ํ์ ์คํฌ๋ฆฝํธ] ํ์ค ๋ผ์ด๋ธ๋ฌ๋ฆฌ filter์ map
ํ์ ์คํฌ๋ฆฝํธ์์ ์ ๊ณตํ๋ filter, map ํจ์๋ฅผ ๋ถ์ํด๋ณด์. map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. * @param thisArg An object to ..
![[ํ์
์คํฌ๋ฆฝํธ] ๊ฐ์ฒด์งํฅ์ ์ผ๋ก Generic Stack<T> ํด๋์ค ๊ตฌํํ๊ธฐ](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FBLMcN%2FbtrArd4IuQp%2F0QmHr3PZQrqoW7C2doFDdk%2Fimg.png)
[ํ์ ์คํฌ๋ฆฝํธ] ๊ฐ์ฒด์งํฅ์ ์ผ๋ก Generic Stack<T> ํด๋์ค ๊ตฌํํ๊ธฐ
ํ๋ก๊ทธ๋๋ฐ์ ๊ฝ, ๊ฐ์ฒด์งํฅ์ ๊ฝ ์ ๋ค๋ฆญ ์ ๋ค๋ฆญ์ ์ด๋ ๊ฐ๋ ํต์์ ์ผ๋ก ๋ณผ ์ ์๋ค.(์ฌ์ฌ์ฉ์ฑ์ด ๊ต์ฅํ ๋๊ธฐ ๋๋ฌธ) ์ด์ ํฌ์คํ stack์ ๋จ์ ์ ์ค๋ก์ง stringํ๋ง push, pop ํ ์ ์๋ค๋ ๊ฒ์ด๋ค. ๋ค์ํ ํ์ ์ push, pop ํ๊ณ ์ถ๋ค๋ฉด ์ ๋ค๋ฆญ์ ์ด์ฉํด์ ํ์ฉ์ฑ๊ณผ ์ฌ์ฌ์ฉ์ฑ์ ๋์ผ ์ ์๋ค. ์ ์ฐํ๊ณ ํ์ ๋ ๋ณด์ฅํ ์ ์๊ณ , ์ฌ์ฌ์ฉ์ ์ ๋ง ๋ง์ด ๋์ผ ์ ์๋ ์ ๋ค๋ฆญ์ ๋ง์คํฐํด๋ณธ๋ค. (์คํ์์ค๋ API ๋ฌธ์๋ฅผ ๋ณผ ๋ ์ ๋ค๋ฆญ์ ์๊ณ ์๋ค๋ฉด ๋งํ์์ด ์ฝ์ ์ ์๋ค.) ๊ฐ์ข ์ ๋ค๋ฆญ ์๋ฃ๊ตฌ์กฐ๋ค๋ 'ํด๋์ค'์ด๋ค. ๊ฐ๋ น C#์ stack ํด๋์ค๋ ๋ค์ ๋งํฌ์ ๊ฐ๋ค. https://docs.microsoft.com/ko-kr/dotnet/api/system.collections.generic.stack-..