2020-03-01ãã1ã¶æéã®è¨äºä¸è¦§
7ç« ã«å ¥ãã ãã«ã¨ãã©ã³ã¯æ¯è¼ã§ããã®ã ãããã¨ããçåããã¹ãã«æ¸ãã¦ã¿ãã¨ããããå§ã¾ãã ãã®æ¬ã®ã³ã¼ãã§ã¯ãequalsã¡ã½ããã¯Objectãåãã¦ããã®ã§ããã«ã¨ãã©ã³ã¯åºå¥ãªã æ±ãããã¹ã¤ã¹çµæ¸ã«å¤§ææãä¸ãã¦ããã ä¸æ¹ãç§ã®Rustã®å®è£ â¦
5ç« ãååãããã¦ç ´ãã¨ããã«å ¥ãã ãã®ç« ã¯ãã¯ã½ã³ã¼ããä½ã£ã¦çµããã ãã ãããããã©ãã«ãããªããã¡ã¯å®¶ã«å¸°ããªããã¨ãèªãã ã¨ãããããä»ã¾ã§ä½ã£ããã«ã¨ã¯å¥ã«ãã©ã³ãä½ãããããåãªãã³ããã§ä½ãã ãã©ã³ã»ã»ã»ãããªé貨åä½ã¯ãâ¦
4ç« ãæå³ãèªããã¹ããã«å ¥ã£ã¦ãããã amountã¨ããå é¨æ§é ãã¤ã³ã¿ã¼ãã§ã¼ã¹ã¨ãã¦å¤ã«åºã¦ããã®ã¯ è¦ã¥ãããè¯ããªãããã¨ãããã¨ã§ãªãã¡ã¯ã¿ãªã³ã°ãã¦ããã ãã£ã¨ãã ã ããããããã¡ãã«ã¯ã³ã³ã¹ãã©ã¯ã¿ãããªãã®ã§ããã®ã¿ã¤ãã³ã°ã§â¦
3ç« ãä¸è§æ¸¬éãã«å ¥ãã DollarãValue Objectã«ãããã¨è¨ãåºããçå¤ã§ãããã¨ããã§ãã¯ã§ããããã«ããã®ã ã¨ã Value Objectã¨ãããã¿ã¼ã³ã«é¦´æã¿ã¯ãªããã ãã©ã ãªãã¸ã§ã¯ããå¤ã¨ãã¦æ±ããã¨ã«ã¯ãããããªé£ããããããã¨ã¯ç¥ã£ã¦ããã â¦
2ç« ãæç½ãªå®è£ ãã«å ¥ãã ä»æ§ãå¤ãã£ããtimesã¡ã½ããã¯Dollarãè¿ãæ§ã«ãªã£ãã ããä»ãç§ã®typoãè¦ã¤ãã£ããDollarãããªãã¦Dollerã«ãªã£ã¦ãã»ã»ã»ã ã¨ããããä»æ§å¤æ´ã®çµæããã¹ãã¯ãããªã£ãã #[test] fn test_multiplication() { let â¦
ããããããã¹ãé§åéçºãã«å ¥ã£ã¦ãããã ã¾ãã¯ãP4ã®æåã®ãã¹ãã ãããããã«åå¨ããªãDollerã¯ã©ã¹ãnewãã¦ã ãããããªãtimesã¡ã½ãããamountãã£ã¼ã«ããåç §ãã¦ããããã¹ããã¡ã¼ã¹ããªã®ã ã ã»ã»ã»Rustã§ãã¼ã¿åã表ç¾ããã®ã¯ã©ããâ¦
æåã«ããã®ã¯cargo newã§ããã > cargo new money Created binary (application) `money` package > cd money > ls -la total 16 drwxr-xr-x 6 tambara staff 192 3 20 17:48 . drwxr-xr-x 3 tambara staff 96 3 20 17:48 .. drwxr-xr-x 8 tambara staff â¦
社å ã§ãã±ã³ãã»ããã¯ã®ããã¹ãé§åéçºããåçµããä¼ãç«ã¡ä¸ãã¦ãã¢ããã¤ã¶ã¼ã¿ãããªãã¨ããããã¨ã«ãªã£ããè¯ãã³ã¼ããæ¸ãã«ã¯ã¾ã åã°ãªãããé ·ããã¹ãã³ã¼ããç´ãçµé¨ãªãã¡ãã£ã¨ãããã®ã§ãã(ç¬)ã ã¨ãããããåå ã¡ã³ãã¼ã¯ãã¾ãâ¦