This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data class User(val name : String, val latLng: LatLng) | |
| data class LatLng(val lat: Int, val lng: Int) | |
| fun deleteDuplicates() { | |
| // create data | |
| val results = (1..10).map {User("$it", LatLng(it % 4, it%4))} | |
| results.forEach { | |
| println(it) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| import GoogleMaps | |
| @UIApplicationMain | |
| class AppDelegate: UIResponder, UIApplicationDelegate { | |
| func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
| // https://developers.google.com/maps/documentation/ios-sdk/get-api-key#add_key | |
| GMSServices.provideAPIKey("YOUR_API_KEY") | |
| return true | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| File().outputStream().use { out -> | |
| bitmap.compress(Bitmap.CompressFormat.JPEG, 85, out) | |
| out.flush() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val num = 'a'.toValue() | |
| println(num) | |
| // Output | |
| // 42 | |
| private fun Char.toValue() : Int{ | |
| // 仕様: https://www.icao.int/publications/Documents/9303_p3_cons_en.pdf の 20ページの最後から21ページの最初 | |
| val num = this.toInt() - '0'.toInt() | |
| if(num < 10) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val amari = 8.rem(3) | |
| println(amari) | |
| // Output | |
| // 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var isContinue:Boolean = true | |
| val list = arrayOf("hello", "good", "text", "hello2", "text2") | |
| val result = list.asSequence().takeWhile{isContinue}.reduce {s1, s2-> | |
| if(s1.length == 4 && s2.length == 4) { | |
| isContinue = false | |
| return@reduce s1+s2 | |
| } | |
| s2 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data class Person(val age:Int, val name:String) { | |
| val greet | |
| get() = "年齢は${age}です" | |
| fun testPrint() { | |
| println("testPrint ${age}" ) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // kotlin 1.3.31 | |
| // MyClass.java | |
| package inline; | |
| import kotlin.Metadata; | |
| import org.jetbrains.annotations.NotNull; | |
| import org.jetbrains.annotations.Nullable; | |
| @Metadata( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private fun Rect.rotateRect(degree:Float): Rect { | |
| val rectF = this.toRectF() | |
| val matrix = Matrix() | |
| matrix.setRotate(degree, rectF.centerX(), rectF.centerY()) | |
| matrix.mapRect(rectF) | |
| return rectF.toRect() | |
| } |