본문 바로가기

기타개발32

Dart #4 : if-else, for/while/do-while, switch, exceptions Dart : https://dart.dev/guides/language/language-tour 1. If and else if, else if 의 조건문은 boolean 값이어야 한다 if (isRaining()) { you.bringRainCoat(); } else if (isSnowing()) { you.wearJacket(); } else { car.putTopDown(); } 여기서 잠깐, Collection if 조건으로 컬렉션의 값을 조정하고 싶을 때 아래처럼 사용한다 var nav = [ 'Home', 'Furniture', 'Plants', if (promoActive) 'Outlet' ]; 2. For loops var message = StringBuffer('Dart is fun').. 2020. 8. 27.
Dart #3 : Operators Dart : https://dart.dev/guides/language/language-tour 0. Operators 기본 : https://dart.dev/guides/language/language-tour#operators 1. Arithmetic operators assert(2 + 3 == 5); assert(2 - 3 == -1); assert(2 * 3 == 6); assert(5 / 2 == 2.5); // 결과 값은 double 타입 assert(5 ~/ 2 == 2); // 나눗셈의 몫으로 결과 값은 int 타입 assert(5 % 2 == 1); // 나눗셈의 나머지로 결과 값은 int 타입 assert('5/2 = ${5 ~/ 2} r ${5 % 2}' == '5/2 = 2 r 1.. 2020. 8. 27.
Dart #2 : Functions Dart : https://dart.dev/guides/language/language-tour Dart 는 객체 지향 언어이다 함수도 객체이며 함수조차도 객체이고 모든 함수 타입의 기본 클래스인 Function 이 있다 이는 함수를 변수에 할당하거나 다른 함수에 인수로 전달할 수 있음을 의미한다 Effective Dart는 public API 에 대한 타입 표시를 권장하지만 생략 가능하다 bool isNoble(int atomicNumber) { return _nobleGases[atomicNumber] != null; } isNoble(atomicNumber) { return _nobleGases[atomicNumber] != null; } // 표현식이 하나인 경우 아래처럼 줄일 수 있다 bool .. 2020. 8. 27.
Dart #1 : Type, Collections, Final, Const etc. Flutter : https://flutter.dev/docs/get-started/install 플러터는 네이티브 코드와 동등한 성능이다 플러터는 Material Design 과 쿠퍼티노 디자인 을 제공한다 플러터는 Dart 언어로 개발한다 구글에서 개발한 웹 프론트엔드 개발용 언어로 현재는 Flutter 개발에 주로 사용된다 문법이 Java/JavaScript 와 비슷하다 구글에서 개발중인 차세대 OS Fuchsia 의 공식 프레임워크이다 Dart : https://dart.dev/guides/language/language-tour 문법 연습 : https://dartpad.dev/ Dart Keywords : dart.dev/guides/language/language-tour#keywords D.. 2020. 8. 26.
Android Networking with coroutines Flow 들어가기전에 Flow 문서를 보고 정리한 포스팅이며 1, 3, 4번은 필수로 학습이 필요하다. -> Flow #1 : Flow builders, operators, context -> Flow #2 : Buffering -> Flow #3 : Composing and flattening flows -> Flow #4 : Exceptions, completions, cancellation 요즘 구글 가이드라인으로 coroutines 이 필수적으로 등장하고 있어서 기존에 서버 API 통신을 위해 사용하던 Rx 를 coroutines Flow 를 사용하는 패턴으로 변경해보려 한다. 기본 구조 MVVM 구조와 서버 API 통신을 위해 Retrofit2 의 조합을 전제로 해본다. 크게 App module 과 서버.. 2020. 8. 6.
Coroutines - Channels https://kotlinlang.org/docs/reference/coroutines/channels.html Channels - Kotlin Programming Language kotlinlang.org 1. Basics Deffered value 는 코루틴 간 단일 값을 전송하고 Channel 은 값 스트림을 전송하는 방법을 제공한다 Channel 은 개념적으로 BlockingQueue 와 매우 유사하지만 put, take 대신 suspend send 와 receive 가 있다 val channel = Channel() launch { // this might be heavy CPU-consuming computation or async logic, we'll just send five squar.. 2020. 7. 30.