다트 16

[Style] no_leading_underscores_for_local_identifiers

다트 공식홈페이지에서 연습문제를 풀다가 no_leading_underscores_for_local_identifiers 를 알게되었다. (에디터에서 바로바로 경고창이 떠서 놀랐다!) https://dart-lang.github.io/linter/lints/no_leading_underscores_for_local_identifiers.html no_leading_underscores_for_local_identifiers no_leading_underscores_for_local_identifiers Group: style Maturity: stable View all Lint Rules Using the Linter DON’T use a leading underscore for identifiers t..

Language/Dart 2022.08.19

[Exercism] Armstrong Numbers #num #math

https://exercism.org/tracks/dart/exercises/armstrong-numbers Armstrong Numbers in Dart on Exercism Can you solve Armstrong Numbers in Dart? Improve your Dart skills with support from our world-class team of mentors. exercism.org 처음에 문제 조건을 잘못 이해해서 조금 해맸다. 먼저 제곱을 계산하기 위해 'dart:math' library를 사용하였다. 그리고 다트에서는 int.parse(String word)를 통해 String 숫자를 int로 변환할 수 있다.(double.parse도 있다!) math의 pow를 사용해서 각..

Language/Dart 2022.08.19

[Exercism] Scrabble Score #가독성 있는 코드란?2

https://exercism.org/tracks/dart/exercises/scrabble-score Scrabble Score in Dart on Exercism Can you solve Scrabble Score in Dart? Improve your Dart skills with support from our world-class team of mentors. exercism.org 이전 Leap랑 같이 가독성 있고, 수정하기 좋은 코드에 대해 얘기를 나눌 수 있었던 문제! 처음에 내가 문제를 풀었던 방식은 1) 단어별 점수 조건을 Map으로 만들고 + 2) 주어진 단어를 List로 변환해서 이중 for문을 사용해서 점수를 구했다. 여기서 또 알게된 재밌는 사실은, 다트는 .dart 파일마다 반드..

Language/Dart 2022.08.18

[Exercism] Leap #가독성 있는 코드란?

https://exercism.org/tracks/dart/exercises/leap Leap in Dart on Exercism Can you solve Leap in Dart? Improve your Dart skills with support from our world-class team of mentors. exercism.org 처음에 문제가 이해되지 않아서(영어 해석이 안됬다...) 한참 헤매다가 테스트코드에 있는 조건들을 보고 문제를 풀었다. 그래서 내가 처음 냈던 답안은 아래와 같다. class Leap { bool leapYear(int year) { return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0); } } 문제를 풀면서 팀원과..

Language/Dart 2022.08.18

[Exercism] Two Fer #Optional positional parameters

https://exercism.org/tracks/dart/exercises/two-fer Two Fer in Dart on Exercism Can you solve Two Fer in Dart? Improve your Dart skills with support from our world-class team of mentors. exercism.org 다트는 optional positional parameters를 사용할 수 있다. 이렇게 default 값을 넣어 줄 수도 있고 String twoFer([String name = 'you']) { return 'One for ${name}, one for me.'; } 아니면 널을 허용한 상태(String?)에서 null일 경우를 분기 처리해주는 방법도..

Language/Dart 2022.08.18

Dart 공부하기

새로운 언어를 공부하게 되었다! 공식문서 https://dart.dev/ 비교적 최근에 나온 언어들이 그렇듯이 공식문서가 굉장히 잘되어있다. Dart programming language Dart is a client-optimized language for fast apps on any platform dart.dev 자바를 하다가 다트를 시작한 느낌은, 1. 객체지향 + 정적 + 컴파일러라서 접근하기 쉽다. 2. Null Safe!!!!! 3. 좀 더 간결하다(생성자의 new 등 자바에서는 반드시 써야했던 것이 많이 생략되어 있다.) DartPad DartPad를 통해 웹에서도 연습할 수 있다. https://dartpad.dev/? DartPad dartpad.dev Flutter를 위한 언어인만큼..

Language/Dart 2022.08.18