Skip to content

Commit da5a173

Browse files
committed
Translate 1 file to ko - Generic Classes
1 parent 874e022 commit da5a173

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

โ€Ždocs/playground/ko/JavaScript/Working With Classes/Generic Classes.ts

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
//// { order: 3 }
22

3-
// This example is mostly in TypeScript, because it is much
4-
// easier to understand this way first. At the end we'll
5-
// cover how to create the same class but using JSDoc instead.
3+
// ๋จผ์ € ์ด ๋ฐฉ์‹์œผ๋กœ ์ดํ•ดํ•˜๋Š” ๊ฒŒ ํ›จ์”ฌ ์‰ฌ์šฐ๋ฏ€๋กœ
4+
// ์˜ˆ์‹œ๋Š” ๋Œ€๋ถ€๋ถ„ TypeScript๋กœ ์ž‘์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค.
5+
// ๋งˆ์ง€๋ง‰์—๋Š” JSDoc์„ ์‚ฌ์šฉํ•˜์—ฌ ๋™์ผํ•œ ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“œ๋Š” ๋ฐฉ๋ฒ•์„ ๋‹ค๋ฃฐ ๊ฒ๋‹ˆ๋‹ค.
66

7-
// Generic Classes are a way to say that a particular type
8-
// depends on another type. For example, here is a drawer
9-
// which can hold any sort of object, but only one type:
7+
// ์ œ๋„ค๋ฆญ ํด๋ž˜์Šค๋Š” ํŠน์ • ํƒ€์ž…์ด ๋‹ค๋ฅธ ํƒ€์ž…์— ๋”ฐ๋ผ ๋™์ž‘ํ•œ๋‹ค๋Š” ๊ฒƒ์„ ๋ณด์—ฌ์ฃผ๋Š” ํ•˜๋‚˜์˜ ๋ฐฉ์‹์ž…๋‹ˆ๋‹ค.
8+
// ์˜ˆ๋ฅผ ๋“ค์–ด, ์—ฌ๊ธฐ์—๋Š” ํ•œ ์ข…๋ฅ˜๋งŒ ์žˆ์ง€๋งŒ
9+
// ์—ฌ๋Ÿฌ ๊ฐ€์ง€ ๋ฌผ๊ฑด์„ ๋‹ด์„ ์ˆ˜ ์žˆ๋Š” ํ•˜๋‚˜์˜ ์„œ๋ž์ด ์žˆ์Šต๋‹ˆ๋‹ค:
1010

1111
class Drawer<ClothingType> {
1212
contents: ClothingType[] = [];
@@ -20,8 +20,8 @@ class Drawer<ClothingType> {
2020
}
2121
}
2222

23-
// In order to use a Drawer, you will need another
24-
// type to work with:
23+
// Drawer๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ
24+
// ๋˜ ๋‹ค๋ฅธ ํƒ€์ž…์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค:
2525

2626
interface Sock {
2727
color: string;
@@ -31,31 +31,31 @@ interface TShirt {
3131
size: "s" | "m" | "l";
3232
}
3333

34-
// We can create a Drawer just for socks by passing in the
35-
// type Sock when we create a new Drawer:
34+
// ์ƒˆ๋กœ์šด Drawer๋ฅผ ๋งŒ๋“ค ๋•Œ Sock ํƒ€์ž…์„ ์ „๋‹ฌํ•˜์—ฌ
35+
// ์–‘๋ง ์ „์šฉ์˜ ์ƒˆ๋กœ์šด Drawer๋ฅผ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:
3636
const sockDrawer = new Drawer<Sock>();
3737

38-
// Now we can add or remove socks to the drawer:
38+
// ์ด์ œ ์–‘๋ง์„ ์„œ๋ž์— ์ถ”๊ฐ€ํ•˜๊ฑฐ๋‚˜ ์‚ญ์ œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:
3939
sockDrawer.add({ color: "white" });
4040
const mySock = sockDrawer.remove();
4141

42-
// As well as creating a drawer for TShirts:
42+
// ํ‹ฐ์…”์ธ ๋ฅผ ์œ„ํ•œ ์„œ๋ž๋„ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:
4343
const tshirtDrawer = new Drawer<TShirt>();
4444
tshirtDrawer.add({ size: "m" });
4545

46-
// If you're a bit eccentric, you could even create a drawer
47-
// which mixes Socks and TShirts by using a union:
46+
// ์—ฌ๋Ÿฌ๋ถ„์ด ์กฐ๊ธˆ ๋ณ„๋‚˜์‹  ํŽธ์ด๋ผ๋ฉด,
47+
// ์œ ๋‹ˆ์–ธ์„ ์‚ฌ์šฉํ•˜์—ฌ ์–‘๋ง๊ณผ ํ‹ฐ์…”์ธ ๊ฐ€ ์„ž์ธ ์„œ๋ž์„ ๋งŒ๋“ค ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค
4848

4949
const mixedDrawer = new Drawer<Sock | TShirt>();
5050

51-
// Creating a class like Drawer without the extra TypeScript
52-
// syntax requires using the template tag in JSDoc. In this
53-
// example we define the template variable, then provide
54-
// the properties on the class:
51+
// ์ถ”๊ฐ€ TypeScript ๊ตฌ๋ฌธ ์—†์ด Drawer์™€ ๊ฐ™์€ ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“œ๋Š” ๊ฒƒ์€
52+
// JSDoc์—์„œ ํ…œํ”Œ๋ฆฟ ํƒœ๊ทธ ์‚ฌ์šฉ์„ ์š”๊ตฌํ•ฉ๋‹ˆ๋‹ค.
53+
// ์ด ์˜ˆ์‹œ์—์„œ ํ…œํ”Œ๋ฆฟ ๋ณ€์ˆ˜๋ฅผ ์ •์˜ํ•˜๊ณ ,
54+
// ํด๋ž˜์Šค์— ํ”„๋กœํผํ‹ฐ๋ฅผ ์ œ๊ณตํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค:
5555

56-
// To have this work in the playground, you'll need to change
57-
// the settings to be a JavaScript file, and delete the
58-
// TypeScript code above
56+
// playground์—์„œ ์ž‘์—…ํ•˜๊ธฐ ์œ„ํ•ด์„œ,
57+
// ์—ฌ๋Ÿฌ๋ถ„์€ JavaScript ํŒŒ์ผ์ด ๋˜๋„๋ก ์„ค์ •์„ ๋ณ€๊ฒฝํ•˜๊ณ 
58+
// ์œ„์— ์žˆ๋Š” TypeScript ์ฝ”๋“œ๋ฅผ ์ œ๊ฑฐํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค
5959

6060
/**
6161
* @template {{}} ClothingType
@@ -77,16 +77,16 @@ class Dresser {
7777
}
7878
}
7979

80-
// Then we create a new type via JSDoc:
80+
// ๊ทธ๋Ÿฌ๊ณ  ๋‚˜์„œ JSDoc์„ ํ†ตํ•ด ์ƒˆ๋กœ์šด ํƒ€์ž…์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค:
8181

8282
/**
83-
* @typedef {Object} Coat An item of clothing
84-
* @property {string} color The colour for coat
83+
* @typedef {Object} Coat ์˜๋ฅ˜ ์•„์ดํ…œ
84+
* @property {string} color ์ฝ”ํŠธ ์ƒ‰์ƒ
8585
*/
8686

87-
// Then when we create a new instance of that class
88-
// we use @type to assign the variable as a Dresser
89-
// which handles Coats.
87+
// Dresser ํด๋ž˜์Šค์˜ ์ƒˆ๋กœ์šด ์ธ์Šคํ„ด์Šค๋ฅผ ์ƒ์„ฑํ•  ๋•Œ
88+
// ์ฝ”ํŠธ๋ฅผ ๋‹ค๋ฃจ๋Š” Dresser๋กœ
89+
// ๋ณ€์ˆ˜๋ฅผ ํ• ๋‹นํ•˜๊ธฐ ์œ„ํ•ด @type์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
9090

9191
/** @type {Dresser<Coat>} */
9292
const coatDresser = new Dresser();

0 commit comments

Comments
ย (0)