kotlin / kotlin-koans Goto Github PK
View Code? Open in Web Editor NEWKotlin workshop
License: MIT License
Kotlin workshop
License: MIT License
/**
* @see <a href="https://kotlinlang.org/docs/reference/lambdas.html#extension-function-expressions">Extension function literals</a>
*/
fun doc36() {}
I would like to learn Kotlin with the help of the Koans but I'm new to IntelliJ and can not figure out how to setup the project such that I can execute something.
What I tried was first to open a project by specifying the directory of the Kotlin Koans. I expected a kind of project file to be found there. And indeed IntelliJ opened something and displayed a directory structure.
But no way to execute something. Then I tried to create a new Kotlin project in the directory. This allowed me to specify the JRE and the libs used. Seemed logical but still no way to execute something.
Then I tried to add a configuration. First I tried Kotlin. But I could not finish it because I don't know the main class. Then I tried to create JUnit based configuration. This gets me "JUnit not found in module 'KotlinKoans'".
I'm still not able to use the code. Some words on how to set this up in IntelliJ would really be helpful. Otherwise Kotlin stays inaccessible to me.
The comments in _18_Properties_.kt
say:
You can open "View -> Tool windows -> Kotlin" and see the bytecode.
but I can't find that menu entry. Maybe it was removed in an update? I'm using IDEA 14.1.4.
Maybe I'm missing something obvious but how should I infer from these tests that task4()
should check if any item in the collections is a multiple of 42 as per the solution in the resolutions branch?
class _04_Lambdas() {
@Test fun contains() {
assertTrue(task4(listOf(1, 2, 3, 126, 555)))
}
@Test fun notContains() {
assertFalse(task4(listOf(44)))
}
}
Would it make sense to rename the tests to something like containsAMultipleOf42()
and doesNotContainAMultipleOf42()
Figure there's a change you guys might want to investigate. I get 237 errors and failure at compilation, all along the lines of
Error:(5, 1) Kotlin: 'public fun todoTask0(): kotlin.Nothing' is already defined in i_introduction._0_Hello_World.Hello
Error:(7, 5) Kotlin: Redeclaration: idea
This is happening with plugin version 1.0.0-beta-2429-IJ143-19
Full output here: https://gist.github.com/hzsweers/7e341269f824c05232e8
On this page: http://try.kotlinlang.org/#/Kotlin%20Koans/Collections/Sort/Task.kt
"sortBy" link points to nonexistent page. It should be named "sortedBy" and point to the corresponding page in documentation.
"sort" link points to correct page, but probably still should be named "sorted" and point to "sorted" page.
Hi,
nowadays content of MyDate.kt
is more objected-like and it does not look fancy (as it could):
data class MyDate(val year: Int, val month: Int, val dayOfMonth: Int) : Comparable<MyDate>{
override fun compareTo(other: MyDate): Int{
if(year != other.year) return year - other.year
if(month != other.month) return month - other.month
return dayOfMonth - other.dayOfMonth
}
}
operator fun MyDate.rangeTo(other: MyDate) = DateRange(this, other)
I think that better purpose for this Kotlin
programming language course would be rewrite existing code using a functional programming paradign. Here's my solution:
data class MyDate(val year: Int, val month: Int, val dayOfMonth: Int) : Comparable<MyDate>{
override fun compareTo(other: MyDate): Int = when {
year != other.year -> year - other.year
month != other.month -> month - other.month
else -> dayOfMonth - other.dayOfMonth
}
}
operator fun MyDate.rangeTo(other: MyDate) = DateRange(this, other)
I must agree that change is pretty small, but as you provide in kotlin-koans
course typical functional structures like lambdas or recursion, maybe it would be better to keep this course and its code functional, than messing it with 'java-like' code.
Although, I found fun in rewriting every MyDate.kt
instance and that was good additional trainign :-D
Hope you would find useful.
Cheers!
Hello,
I've spotted a Test class that, I think shouldn't be ok.
The todo in iii_conventions/_27_Rangeto.kt
asks for implementing the MyDate.rangeTo()
function in MyDate.kt.
However, commenting it shows no compilation error, and the tests actually pass (see screenshot below).
I may understand why it works, but still think than, according to the Todo :
To make '..' work implement a 'MyDate.rangeTo()' extension function returning DateRange.
it shouldn't.
While importing the repository in Android Studio 3.0.1 , got this error
10:31 AM Gradle sync failed: Could not initialize class org.jetbrains.kotlin.gradle.KotlinGradleModelBuilder Consult IDE log for more details (Help | Show Log) (354ms)
Update gradle distribution url to use gradle-4.1-all.zip, causes the error to go away.
var propertyWithCounter: Int? = null
set(v : Int?) {
field = v
counter++
}
On this page: http://try.kotlinlang.org/#/Kotlin%20Koans/Collections/Max%20min/Task.kt
"maxBy" link points to "max" page.
Hey folks,
Just getting into Kotlin and I had a hard time importing the koans into Intellij. Can we make it a Maven project and/or remove the editor settings (e.g., Eclipse files like .project)?
I understand the koans were mostly thought out for IDE users, but I believe there are many people who prefer doing their coding work with just the command line and text editors such as me.
The problem with running the koans using ./gradlew test
is that the output is very messy, and you need to sift through it in order to find out if the test you were working on has passed. Of course, you can run the individual test you're working on, but a lot of Kotlin newcomers are also newcomers to Gradle and won't know how to do that.
Most other "koans" projects such as ruby-koans provide a script you can run which will tell you the first koan to fail among all of them and no other information. I find that to be the best way to have koans gently introduce newcomers to a language. It would be nice to have a script like that for kotlin-koans too.
Why is this line present, from test/iii_conventions/_25_Comparison.kt
:
operator fun MyDate.compareTo(other: MyDate): Int = todoTask25()
I think its presence allows the test code to compile, but if you add the operator extension function to MyDate.kt
, this line in the test file is still used so the test is still broken. By commenting it out, the test passed for me.
Hi,
I have imported the project and opened it via Intellij Idea and get this error and thanks in advance:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'kotlin-koans'.
at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:79)
at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:57)
at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:573)
at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:125)
at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:42)
at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:38)
at org.gradle.initialization.DefaultGradleLauncher$2.run(DefaultGradleLauncher.java:124)
at org.gradle.internal.Factories$1.create(Factories.java:22)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:53)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:121)
at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:98)
at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:92)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:63)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:92)
at org.gradle.initialization.DefaultGradleLauncher.getBuildAnalysis(DefaultGradleLauncher.java:88)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.configure(InProcessBuildActionExecuter.java:102)
at org.gradle.tooling.internal.provider.runner.ClientProvidedBuildActionRunner.run(ClientProvidedBuildActionRunner.java:45)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.tooling.internal.provider.runner.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:58)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:82)
at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:49)
at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:59)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:49)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
at org.gradle.util.Swapper.swap(Swapper.java:38)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.HintGCAfterBuild.execute(HintGCAfterBuild.java:44)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:240)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':classpath'.
at org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration.rethrowFailure(DefaultLenientConfiguration.java:62)
at org.gradle.api.internal.artifacts.ivyservice.DefaultResolvedConfiguration.rethrowFailure(DefaultResolvedConfiguration.java:36)
at org.gradle.api.internal.artifacts.ivyservice.SelfResolvingDependencyConfigurationResolver$FilesAggregatingResolvedConfiguration.rethrowFailure(SelfResolvingDependencyConfigurationResolver.java:112)
at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingConfigurationResolver$ErrorHandlingResolvedConfiguration.rethrowFailure(ErrorHandlingConfigurationResolver.java:189)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getFiles(DefaultConfiguration.java:684)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.getFiles(DefaultConfiguration.java:314)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration_Decorated.getFiles(Unknown Source)
at org.gradle.api.internal.initialization.DefaultScriptHandler.getScriptClassPath(DefaultScriptHandler.java:69)
at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.defineScriptHandlerClassScope(DefaultPluginRequestApplicator.java:190)
at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugins(DefaultPluginRequestApplicator.java:75)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:157)
at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:38)
at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:25)
at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55)
... 56 more
Caused by: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.10.
Required by:
:kotlin-koans:unspecified
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver.resolveModule(RepositoryChainComponentMetaDataResolver.java:83)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver.resolve(RepositoryChainComponentMetaDataResolver.java:59)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.ComponentResolversChain$ComponentMetaDataResolverChain.resolve(ComponentResolversChain.java:80)
at org.gradle.api.internal.artifacts.ivyservice.clientmodule.ClientModuleResolver.resolve(ClientModuleResolver.java:44)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder$ModuleVersionResolveState.resolve(DependencyGraphBuilder.java:564)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder$ModuleVersionResolveState.getMetaData(DependencyGraphBuilder.java:574)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder$DependencyEdge.calculateTargetConfigurations(DependencyGraphBuilder.java:260)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder$DependencyEdge.attachToTargetConfigurations(DependencyGraphBuilder.java:234)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder.traverseGraph(DependencyGraphBuilder.java:141)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder.resolve(DependencyGraphBuilder.java:79)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultArtifactDependencyResolver.resolve(DefaultArtifactDependencyResolver.java:85)
at org.gradle.api.internal.artifacts.ivyservice.CacheLockingArtifactDependencyResolver$1.run(CacheLockingArtifactDependencyResolver.java:41)
at org.gradle.internal.Factories$1.create(Factories.java:22)
at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:192)
at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:175)
at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:106)
at org.gradle.cache.internal.DefaultCacheFactory$ReferenceTrackingCache.useCache(DefaultCacheFactory.java:187)
at org.gradle.api.internal.artifacts.ivyservice.DefaultCacheLockingManager.useCache(DefaultCacheLockingManager.java:64)
at org.gradle.api.internal.artifacts.ivyservice.CacheLockingArtifactDependencyResolver.resolve(CacheLockingArtifactDependencyResolver.java:39)
at org.gradle.api.internal.artifacts.ivyservice.DefaultConfigurationResolver.resolve(DefaultConfigurationResolver.java:91)
at org.gradle.api.internal.artifacts.ivyservice.SelfResolvingDependencyConfigurationResolver.resolve(SelfResolvingDependencyConfigurationResolver.java:40)
at org.gradle.api.internal.artifacts.ivyservice.ShortCircuitEmptyConfigurationResolver.resolve(ShortCircuitEmptyConfigurationResolver.java:62)
at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingConfigurationResolver.resolve(ErrorHandlingConfigurationResolver.java:43)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveGraphIfRequired(DefaultConfiguration.java:393)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveNow(DefaultConfiguration.java:368)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.getResolvedConfiguration(DefaultConfiguration.java:361)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration_Decorated.getResolvedConfiguration(Unknown Source)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getFiles(DefaultConfiguration.java:682)
... 66 more
Caused by: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.10.
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ErrorHandlingModuleComponentRepository$ErrorHandlingModuleComponentRepositoryAccess.resolveComponentMetaData(ErrorHandlingModuleComponentRepository.java:91)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ComponentMetaDataResolveState.process(ComponentMetaDataResolveState.java:66)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ComponentMetaDataResolveState.resolve(ComponentMetaDataResolveState.java:58)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver.findBestMatch(RepositoryChainComponentMetaDataResolver.java:116)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver.findBestMatch(RepositoryChainComponentMetaDataResolver.java:99)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver.resolveModule(RepositoryChainComponentMetaDataResolver.java:72)
... 93 more
Caused by: org.gradle.api.resources.ResourceException: Could not get resource 'https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.10/kotlin-gradle-plugin-1.2.10.pom'.
at org.gradle.internal.resource.ResourceExceptions.failure(ResourceExceptions.java:69)
at org.gradle.internal.resource.ResourceExceptions.getFailed(ResourceExceptions.java:52)
at org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver.downloadStaticResource(DefaultExternalResourceArtifactResolver.java:95)
at org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver.resolveArtifact(DefaultExternalResourceArtifactResolver.java:54)
at org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver.parseMetaDataFromArtifact(ExternalResourceResolver.java:192)
at org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver.resolveStaticDependency(ExternalResourceResolver.java:171)
at org.gradle.api.internal.artifacts.repositories.resolver.MavenResolver.doResolveComponentMetaData(MavenResolver.java:93)
at org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver$RemoteRepositoryAccess.resolveComponentMetaData(ExternalResourceResolver.java:442)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CacheLockReleasingModuleComponentsRepository$LockReleasingRepositoryAccess$2.run(CacheLockReleasingModuleComponentsRepository.java:71)
at org.gradle.internal.Factories$1.create(Factories.java:22)
at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:242)
at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:313)
at org.gradle.cache.internal.DefaultPersistentDirectoryStore.longRunningOperation(DefaultPersistentDirectoryStore.java:114)
at org.gradle.cache.internal.DefaultCacheFactory$ReferenceTrackingCache.longRunningOperation(DefaultCacheFactory.java:179)
at org.gradle.api.internal.artifacts.ivyservice.DefaultCacheLockingManager.longRunningOperation(DefaultCacheLockingManager.java:56)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CacheLockReleasingModuleComponentsRepository$LockReleasingRepositoryAccess.resolveComponentMetaData(CacheLockReleasingModuleComponentsRepository.java:69)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository$ResolveAndCacheRepositoryAccess.resolveComponentMetaData(CachingModuleComponentRepository.java:297)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.BaseModuleComponentRepositoryAccess.resolveComponentMetaData(BaseModuleComponentRepositoryAccess.java:42)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.memcache.InMemoryCachedModuleComponentRepository$CachedAccess.resolveComponentMetaData(InMemoryCachedModuleComponentRepository.java:75)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ErrorHandlingModuleComponentRepository$ErrorHandlingModuleComponentRepositoryAccess.resolveComponentMetaData(ErrorHandlingModuleComponentRepository.java:89)
... 98 more
Caused by: org.gradle.internal.resource.transport.http.HttpRequestException: Could not GET 'https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.10/kotlin-gradle-plugin-1.2.10.pom'.
at org.gradle.internal.resource.transport.http.HttpClientHelper.performRequest(HttpClientHelper.java:72)
at org.gradle.internal.resource.transport.http.HttpClientHelper.performRawGet(HttpClientHelper.java:58)
at org.gradle.internal.resource.transport.http.HttpClientHelper.performGet(HttpClientHelper.java:62)
at org.gradle.internal.resource.transport.http.HttpResourceAccessor.openResource(HttpResourceAccessor.java:51)
at org.gradle.internal.resource.transport.http.HttpResourceAccessor.openResource(HttpResourceAccessor.java:34)
at org.gradle.internal.resource.transfer.DefaultExternalResourceConnector.openResource(DefaultExternalResourceConnector.java:56)
at org.gradle.internal.resource.transfer.ProgressLoggingExternalResourceAccessor.openResource(ProgressLoggingExternalResourceAccessor.java:36)
at org.gradle.internal.resource.transport.DefaultExternalResourceRepository.getResource(DefaultExternalResourceRepository.java:63)
at org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor.getResource(DefaultCacheAwareExternalResourceAccessor.java:76)
at org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver.downloadStaticResource(DefaultExternalResourceArtifactResolver.java:86)
... 115 more
Caused by: javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1959)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1916)
at sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1899)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1420)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:394)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:353)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.gradle.internal.resource.transport.http.HttpClientHelper.performHttpRequest(HttpClientHelper.java:102)
at org.gradle.internal.resource.transport.http.HttpClientHelper.executeGetOrHead(HttpClientHelper.java:79)
at org.gradle.internal.resource.transport.http.HttpClientHelper.performRequest(HttpClientHelper.java:70)
... 124 more
Caused by: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
at sun.security.validator.PKIXValidator.(PKIXValidator.java:91)
at sun.security.validator.Validator.getInstance(Validator.java:179)
at sun.security.ssl.X509TrustManagerImpl.getValidator(X509TrustManagerImpl.java:312)
at sun.security.ssl.X509TrustManagerImpl.checkTrustedInit(X509TrustManagerImpl.java:171)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:184)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1496)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1026)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:961)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1072)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413)
... 139 more
Caused by: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
at java.security.cert.PKIXParameters.setTrustAnchors(PKIXParameters.java:200)
at java.security.cert.PKIXParameters.(PKIXParameters.java:120)
at java.security.cert.PKIXBuilderParameters.(PKIXBuilderParameters.java:104)
at sun.security.validator.PKIXValidator.(PKIXValidator.java:89)
... 151 more
"No license" modifications are prohibited. Whether this would be intentional?
If you allow the modification, I hope that you set the appropriate license.
// Browse the Kotlin tool window in IntelliJ IDEA for details.
I'm not certain what this is. Is this related to #26? Is this supposed to be the bytecode viewer?
Hi,
inspired by the talk of Svetlana on the JavaLand i just started to learn a bit kotlin. Sadly the koans won't compile on my machine. I'm using IntelliJ12 Ultimate (on OpenJDK 7) so i'm not sure if my plugin may be outdated. On the other hand i don't know how to integrate the local installation of the "kotlinc-jvm" bundle into IntelliJ - assuming that my problem is related to an old version of the kotlin compiler.
Here is a screenshot of the compiler problem:
Greetings
Torben
Thank you for the project!
I've just got it working in Android Studio, and am now learning Kotlin - but it took a bit of playing around with to get there.
I think "To build the project and run tests use 'test' task on Gradle panel." in the README could do with expanding a bit; specifically that "test" is found in Koans->Tasks->verification->test. Also "Gradle panel" was a bit vague. I didn't even notice it there, on the right of my screen, to begin with!
Cheers,
Ben.
Is there a reason why assert methods are not imported in koans, e.g. Assert.assertEquals(...)
instead of assertEquals(...)
? If there is no particular reason, is it worth making a pull request?
The proposed correct solution states that the partitionTo
function signature should look like this:
fun <T, C: MutableCollection<T>> Collection<T>.partitionTo(first: C, second: C, predicate: (T) -> Boolean): Pair<C, C> {
However, this restricts us to having both first
and second
collections of the same type. Shouldn't different types (e.g. a list and a set) be allowed? And how to implement this?
Before reading the solution I tried this signature:
fun <T, C1: MutableCollection<in T>, C2: MutableCollection<T>> Iterable<T>.partitionTo(c1: C1, c2: C2, predicate: (T) -> Boolean): Pair<C1, C2> {
but it gives a type mismatch error: inferred type kotlin.List<kotlin.String> is not a subtype of kotlin.MutableCollection<kotlin.String>
(when this function is used like partitionTo(ArrayList<String>(), ArrayList()) { s -> !s.contains(" ") }
).
Current:
assertEquals(setOf(idea), testShop.getSetOfProductsOrderedByEveryCustomer())
Correct:
assertEquals(setOf(idea, webStorm, youTrack), testShop.getSetOfProductsOrderedByEveryCustomer())
testBuildString()
and testBuildMap()
use identical functions to calculate expected and actual. This is confusing.
The instructions for task 28 suggests that MyDate.nextDay()
should be utilized. The DateIterator
in the resolution doesn't.
I think the solution to 23 could be simplified by leaving out the Customer.getOrderedProductsList()
extension function and just chaining two flatMap
operations like this:
fun Shop.getNumberOfTimesProductWasOrdered(product: Product): Int {
// Return the number of times the given product was ordered.
// Note: a customer may order the same product for several times.
return customers.flatMap { it.orders }.flatMap { it.products }.count { it == product }
}
In exercise 9, the use of String.lastChar
requires it's declaration, even though it's not part of the actual koan.
Now that Kotlin is an official language for Android, can you fix this:
https://discuss.kotlinlang.org/t/kotlin-koans/2808
I taught Kotlin last weekend to Android developers, and they had to call gradlew test
after each change. Installing InteliJ just to do koans is a bit too much.
Hi,
I'm trying to use Navigate -> Test and it just pops up the "Create New Test..." dialog. Can the koans be configured so this works to be able to jump back and forth between code and test?
According to the java doc, the java.util.Comparator
should do the follwing:
Compares its two arguments for order. Returns a negative integer,
zero, or a positive integer as the first argument is less than, equal
to, or greater than the second.
The current suggested resolution is:
Collections.sort(arrayList, object : Comparator<Int> {
override fun compare(x: Int, y: Int) = y - x
})
which does the opposite - it returns a positive number if the first argument is less than the second, and a negative if the first argument is greater than the second.
I suggest changing the solution to:
Collections.sort(arrayList, object : Comparator<Int> {
override fun compare(x: Int, y: Int) = x - y
})
and the test to:
class N10ObjectExpressionsKtTest {
@Test fun testSort() {
assertEquals(listOf(1, 2, 5), task10())
}
}
Error:(6, 31) Kotlin: Accidental override: The following declarations have the same JVM signature (getMessage()Ljava/lang/String;):
fun <get-message>(): kotlin.String
fun getMessage(): kotlin.String?
Just cloned and I get the following:
./gradlew test
FAILURE: Build failed with an exception.
* Where:
Build file '/workspace/kotlin-koans/build.gradle' line: 15
* What went wrong:
A problem occurred evaluating root project 'kotlin-koans'.
> Failed to apply plugin [id 'kotlin2js']
> Cannot add extension with name 'kotlin', as there is an extension already registered with that name.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 0.762 secs
I can't think of any scenario where I would solve the Collections Fold task using fold
efficiently. I think it should be changed to showcase a realistic scenario for fold
. This task could be reused as an example for reduce
though. Here is a solution I think is good for this task.
val customerProductSets = this.customers.map {
it.orders.flatMap { it.products }.toSet()
}
if (customerProductSets.isEmpty()) {
return emptySet<Product>()
}
return customerProductSets.reduce { acc, products -> acc.intersect(products) }
Or an even more optimized solution:
if (this.customers.isEmpty()) return emptySet<Product>()
return this.customers.asSequence()
.map { it.orders.flatMap { it.products }.toSet() }
.reduce { acc, products ->
acc.intersect(products)
}
In the first koan introduction text, there is a mistake that had me confused for a little bit:
Using 'documentation' argument you can open the related part of Kotlin online documentation.
Press 'F1' (Quick Documentation) on 'doc0()', "See also" section gives you a link.
Pressing 'F1' doesn't open the quick documentation, it opens up the IDE help dialog. The correct way was the shortcut 'Ctrl - Q'.
In fact, most of that introduction description was a little strange to read and not the easiest to follow. If I understand it correctly, it should probably read something like this instead:
Introduction:
What is usually required in these tasks is to change a function 'taskN' (the first seen below as 'task0') by
replacing its body with the correct code according to the problem.
The body of 'TaskN' will start off as an invocation of the function 'todoTaskN()', which throws an
exception, so you usually have to replace that invocation with meaningful code.
In the 'todoTaskN()' function, you can use the various named arguments of the immediately called
'TODO()' function to help you along the way:
Using the 'documentation' argument you can open the related part of the Kotlin online documentation
for the current problem. Using the shortcut 'Ctrl - Q' (Quick Documentation) on 'doc0()' will show you
the function's documentation, the "See also" section gives you the link.
Using the 'references' argument you can usually navigate and see the code mentioned in the task
description. Holding down 'Ctrl' and clicking on the function (in this case 'task0()'), or using the shortcut
'Ctrl - B' on it, will allow you to jump there quickly.
So, on to the first task! Please make the function 'task0' return "OK".
I hope that can be of some help. If you'd like me to make a pull request I'd be happy to.
Task 5.
Copy the body of 'getPattern()' to the 'task5()' function
and rewrite it in such a way that it matches '13 JUN 1992'.
Use the 'month' variable.
I cannot pass the test in "i_introduction _5_String_Templates"
How do I pass this using getPattern() and โmonthโ variable?
I'd clicked on "Fill answer placeholders" to compare with my answer and I saw this code:
val month = "(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)"
fun getPattern(): String = """\d{2} ${month} \d{4}"""
As I'd written my answer without these brackets and it worked as well as with them, I feel a bit confuse if using curly brackets in this exact example is correct. Do I need to write curly brackets in examples as above?
I tried to compile kotlin-koans/src/i_introduction/_0_Hello_World/HelloWorld.kt
with kotlinc HelloWorld.kt -include-runtime -d HelloWorld.jar
but it fails:
HelloWorld.kt:3:8: error: unresolved reference: util
import util.TODO
^
I googled for an hour, read the documentation but I couldn't find out how to do that properly.
RT
Do you think using it
in the lambda would be more idiomatic Kotlin? I will make a PR if people agree with me.
e.g.
collection.any { it % 2 == 0 }
On http://try.kotlinlang.org/ looks like Collections/Fold test is incorrect.
The following code is not acceptied:
// Return the set of products that were ordered by every customer
fun Shop.getProductsOrderedByAllCustomers(): Set<Product> = customers.fold(emptySet(), {
partProduct, element ->
partProduct + element.orders.flatMap { it.products}
})
and the test fails with the following message:
java.lang.AssertionError:
Expected: ['IntelliJ IDEA Ultimate' for 199.0]
Actual: ['IntelliJ IDEA Ultimate' for 199.0, 'WebStorm' for 49.0, 'YouTrack' for 500.0]
<click to see a difference>
at org.junit.Assert.fail(Assert.java:93)
at org.junit.Assert.failNotEquals(Assert.java:647)
at org.junit.Assert.assertEquals(Assert.java:128)
at org.junit.Assert.assertEquals(Assert.java:147)
at TestFold.testGetProductsOrderedByAllCustomers(Test.kt:16)
The test looks invalid:
Assert.assertEquals(setOf(idea), testShop.getProductsOrderedByAllCustomers())
since according to description the set should contain all products from all customers.
In i_introduction._5_Nullable_Types , the first example given in the function struggleAgainstNPE actually does compile but the comment says it doesn't.
Was there a language change regarding using Ranges in a forEach loop? (I'm on kotlin 1.0 beta)
In iii_conventions/_RangeTo.kt :
for (date in firstDate..secondDate) {
handler(date)
}
Will not compile for me. I am pretty sure I have my DateRange implemented correctly.
Thank you! Loving Kotlin!
How to run single test with IDEA?
When I'm selecting _00_Start
and Run testOk()
IDEA is trying to compile whole project and fails with 248 errors.`
Information:Kotlin: Kotlin JPS plugin version 0.10.195.1
Information:Kotlin: Using kotlin-home = /home/martynas/.IdeaIC14/config/plugins/Kotlin/kotlinc
Information:Kotlin: Kotlin Compiler version 0.10.195.1
Information:7/6/15 1:01 PM - Compilation completed with 240 errors and 90 warnings in 8 sec
/home/martynas/sandbox/workshop-jb/src/vi_generics/_28_GenericFunctions.kt
Error:(17, 25) Kotlin: To specify a type of a parameter or a return type, use the full notation: {(parameter : Type) : ReturnType -> ...}
Error:(17, 37) Kotlin: Expecting parameter name
Error:(17, 24) Kotlin: Cannot infer a type for this parameter. To specify it explicitly use the {(p : Type) -> ...} notation
Error:(18, 27) Kotlin: Unresolved reference: it
/home/martynas/sandbox/workshop-jb/src/v_collections/todoUtil.kt
Error:(10, 28) Kotlin: To specify a type of a parameter or a return type, use the full notation: {(parameter : Type) : ReturnType -> ...}
Error:(10, 35) Kotlin: Expecting parameter name
Error:(10, 24) Kotlin: Cannot infer a type for this parameter. To specify it explicitly use the {(p : Type) -> ...} notation
/home/martynas/sandbox/workshop-jb/src/syntax/lambdas.kt
Error:(14, 11) Kotlin: Expecting an expression
Error:(14, 11) Kotlin: Expecting ')'
Error:(14, 44) Kotlin: Unexpected tokens (use ';' to separate expressions on the same line)
Error:(16, 15) Kotlin: Expecting an expression
Error:(16, 19) Kotlin: Expecting function name or receiver type
Error:(14, 16) Kotlin: Unresolved reference: x
Error:(14, 24) Kotlin: Unresolved reference: y
Error:(14, 39) Kotlin: Unresolved reference: x
Error:(14, 43) Kotlin: Unresolved reference: y
Error:(17, 11) Kotlin: Variable 'sum1' must be initialized
/home/martynas/sandbox/workshop-jb/src/syntax/forWhileLoops.kt
Error:(27, 14) Kotlin: Unexpected tokens (use ';' to separate expressions on the same line)
Error:(28, 18) Kotlin: Unexpected tokens (use ';' to separate expressions on the same line)
Error:(27, 5) Kotlin: Unresolved reference: outerLoop
Warning:(27, 29) Kotlin: The function literal is unused. If you mean block, you can use 'run { ... }'
Error:(28, 9) Kotlin: Unresolved reference: innerLoop
Error:(29, 17) Kotlin: Unresolved reference: i
Error:(30, 17) Kotlin: The label '@innerLoop' does not denote a loop
Error:(30, 25) Kotlin: Unresolved reference: @innerLoop
Error:(33, 17) Kotlin: The label '@outerLoop' does not denote a loop
Error:(33, 22) Kotlin: Unresolved reference: @outerLoop
/home/martynas/sandbox/workshop-jb/src/syntax/operatorOverloading.kt
Error:(9, 13) Kotlin: Expecting a top level declaration
Error:(11, 1) Kotlin: Expecting a top level declaration
Error:(24, 13) Kotlin: Expecting a top level declaration
Error:(39, 1) Kotlin: Expecting a top level declaration
Error:(41, 1) Kotlin: Expecting a top level declaration
Error:(41, 10) Kotlin: Expecting a top level declaration
Error:(41, 11) Kotlin: Expecting a top level declaration
Error:(41, 12) Kotlin: Expecting a top level declaration
Error:(41, 32) Kotlin: Expecting a top level declaration
Error:(41, 33) Kotlin: Expecting a top level declaration
Error:(41, 35) Kotlin: Expecting a top level declaration
Error:(41, 36) Kotlin: Expecting a top level declaration
Error:(41, 48) Kotlin: Expecting a top level declaration
Error:(41, 49) Kotlin: Expecting a top level declaration
Error:(62, 13) Kotlin: Expecting a top level declaration
Error:(68, 1) Kotlin: Expecting a top level declaration
Error:(76, 27) Kotlin: Expecting a top level declaration
Error:(78, 1) Kotlin: Expecting a top level declaration
Error:(90, 23) Kotlin: Expecting a top level declaration
Error:(93, 1) Kotlin: Expecting a top level declaration
Error:(10, 5) Kotlin: Function 'compareTo' must have a body
Error:(10, 26) Kotlin: Unresolved reference: C
Error:(13, 14) Kotlin: Unresolved reference: C
Error:(13, 21) Kotlin: Unresolved reference: C
Error:(26, 5) Kotlin: Function 'plus' must have a body
Error:(27, 5) Kotlin: Function 'minus' must have a body
Error:(29, 5) Kotlin: Function 'inc' must have a body
Error:(29, 16) Kotlin: Unresolved reference: B
Error:(30, 5) Kotlin: Function 'dec' must have a body
Error:(30, 16) Kotlin: Unresolved reference: B
Error:(33, 5) Kotlin: Function 'plus' must have a body
Error:(33, 17) Kotlin: Unresolved reference: A
Error:(33, 21) Kotlin: Unresolved reference: B
Error:(34, 5) Kotlin: Function 'minus' must have a body
Error:(34, 18) Kotlin: Unresolved reference: A
Error:(34, 22) Kotlin: Unresolved reference: B
Error:(35, 5) Kotlin: Function 'times' must have a body
Error:(35, 18) Kotlin: Unresolved reference: A
Error:(35, 22) Kotlin: Unresolved reference: B
Error:(36, 5) Kotlin: Function 'div' must have a body
Error:(36, 16) Kotlin: Unresolved reference: A
Error:(36, 20) Kotlin: Unresolved reference: B
Error:(37, 5) Kotlin: Function 'mod' must have a body
Error:(37, 16) Kotlin: Unresolved reference: A
Error:(37, 20) Kotlin: Unresolved reference: B
Error:(38, 5) Kotlin: Function 'rangeTo' must have a body
Error:(38, 20) Kotlin: Unresolved reference: A
Error:(38, 24) Kotlin: Unresolved reference: B
Error:(42, 33) Kotlin: Unresolved reference: A
Error:(42, 39) Kotlin: Unresolved reference: B
Error:(57, 8) Kotlin: Assignment operators ambiguity:
internal open fun <ERROR FUNCTION>(): [ERROR : <ERROR FUNCTION RETURN TYPE>] defined in root package
internal open fun <ERROR FUNCTION>(): [ERROR : <ERROR FUNCTION RETURN TYPE>] defined in root package
Warning:(59, 10) Kotlin: The value 'b1 + a' assigned to 'var b1: [ERROR : B] defined in syntax.operatorOverloading.binaryAndUnaryOperations' is never used
Error:(63, 5) Kotlin: Function 'plusAssign' must have a body
Error:(63, 23) Kotlin: Unresolved reference: A
Error:(64, 5) Kotlin: Function 'minusAssign' must have a body
Error:(64, 24) Kotlin: Unresolved reference: A
Error:(65, 5) Kotlin: Function 'timesAssign' must have a body
Error:(65, 24) Kotlin: Unresolved reference: A
Error:(66, 5) Kotlin: Function 'divAssign' must have a body
Error:(66, 22) Kotlin: Unresolved reference: A
Error:(67, 5) Kotlin: Function 'modAssign' must have a body
Error:(67, 22) Kotlin: Unresolved reference: A
Error:(70, 29) Kotlin: Unresolved reference: D
Error:(70, 35) Kotlin: Unresolved reference: A
Error:(71, 7) Kotlin: Assignment operators ambiguity:
internal open fun <ERROR FUNCTION>(): [ERROR : <ERROR FUNCTION RETURN TYPE>] defined in root package
internal open fun <ERROR FUNCTION>(): [ERROR : <ERROR FUNCTION RETURN TYPE>] defined in root package
Error:(77, 5) Kotlin: Function 'contains' must have a body
Error:(77, 21) Kotlin: Unresolved reference: E
Error:(80, 24) Kotlin: Unresolved reference: MyCollection
Error:(80, 37) Kotlin: Unresolved reference: A
Error:(80, 44) Kotlin: Unresolved reference: A
Error:(91, 5) Kotlin: Function 'get' must have a body
Error:(91, 16) Kotlin: Unresolved reference: K
Error:(91, 20) Kotlin: Unresolved reference: V
Error:(92, 5) Kotlin: Function 'set' must have a body
Error:(92, 16) Kotlin: Unresolved reference: K
Error:(92, 22) Kotlin: Unresolved reference: V
Error:(95, 27) Kotlin: Unresolved reference: MyMap
Error:(95, 33) Kotlin: Unresolved reference: A
Error:(95, 36) Kotlin: Unresolved reference: B
Error:(95, 43) Kotlin: Unresolved reference: A
Error:(95, 49) Kotlin: Unresolved reference: B
/home/martynas/sandbox/workshop-jb/src/syntax/enums.kt
Error:(4, 11) Kotlin: Expecting an enum entry or member declaration
Error:(10, 8) Kotlin: Expecting an enum entry or member declaration
Error:(10, 9) Kotlin: Expecting an enum entry or member declaration
Error:(10, 17) Kotlin: Expecting an enum entry or member declaration
Error:(10, 18) Kotlin: Expecting an enum entry or member declaration
Error:(11, 10) Kotlin: Expecting an enum entry or member declaration
Error:(11, 11) Kotlin: Expecting an enum entry or member declaration
Error:(11, 19) Kotlin: Expecting an enum entry or member declaration
Error:(11, 20) Kotlin: Expecting an enum entry or member declaration
Error:(12, 9) Kotlin: Expecting an enum entry or member declaration
Error:(12, 10) Kotlin: Expecting an enum entry or member declaration
Error:(12, 18) Kotlin: Expecting an enum entry or member declaration
Error:(18, 6) Kotlin: Expecting an enum entry or member declaration
Error:(10, 5) Kotlin: Missing delegation specifier 'Color'
Error:(11, 5) Kotlin: Missing delegation specifier 'Color'
Error:(12, 5) Kotlin: Missing delegation specifier 'Color'
/home/martynas/sandbox/workshop-jb/src/syntax/qualifiedThis.kt
Error:(9, 45) Kotlin: Label must be named
Error:(14, 26) Kotlin: To specify a type of a parameter or a return type, use the full notation: {(parameter : Type) : ReturnType -> ...}
Error:(14, 35) Kotlin: Expecting parameter name
Error:(21, 13) Kotlin: Expecting a top level declaration
Error:(21, 26) Kotlin: Expecting a top level declaration
Error:(22, 13) Kotlin: Expecting a top level declaration
Error:(22, 26) Kotlin: Expecting a top level declaration
Error:(23, 13) Kotlin: Expecting a top level declaration
Error:(23, 26) Kotlin: Expecting a top level declaration
Error:(27, 15) Kotlin: Label must be named
Error:(28, 19) Kotlin: Label must be named
Warning:(9, 17) Kotlin: Variable 'fl' is never used
Error:(9, 44) Kotlin: Unresolved reference: S
Error:(10, 31) Kotlin: Unresolved reference: @S
Error:(11, 29) Kotlin: Unresolved reference: @S
Warning:(14, 17) Kotlin: Variable 'fl2' is never used
Error:(14, 25) Kotlin: Cannot infer a type for this parameter. To specify it explicitly use the {(p : Type) -> ...} notation
Error:(24, 5) Kotlin: Unresolved reference: B
Error:(24, 14) Kotlin: Unresolved reference: C
Error:(26, 43) Kotlin: Unresolved reference: A
Error:(26, 49) Kotlin: Unresolved reference: B
Error:(27, 12) Kotlin: No value passed for parameter f
Error:(28, 16) Kotlin: No value passed for parameter f
Error:(29, 13) Kotlin: Unresolved reference: foo
Error:(30, 17) Kotlin: 'this' is not defined in this context
Error:(30, 25) Kotlin: 'this' is not defined in this context
Error:(33, 17) Kotlin: 'this' is not defined in this context
Error:(34, 21) Kotlin: Unresolved reference: @B
Error:(35, 21) Kotlin: Unresolved reference: @A
/home/martynas/sandbox/workshop-jb/src/syntax/classesObjectsInterfaces.kt
Error:(4, 27) Kotlin: Expecting a top level declaration
Error:(7, 1) Kotlin: Expecting a top level declaration
Error:(49, 55) Kotlin: Expecting an expression
Error:(49, 55) Kotlin: Expecting ')'
Error:(49, 62) Kotlin: Expecting a top level declaration
Error:(49, 67) Kotlin: Expecting a top level declaration
Error:(49, 69) Kotlin: Expecting a top level declaration
Error:(54, 22) Kotlin: Name expected
Error:(57, 1) Kotlin: Expecting a top level declaration
Error:(5, 5) Kotlin: Function 'foo' must have a body
Error:(15, 19) Kotlin: Unresolved reference: SimpleInterface
Error:(15, 36) Kotlin: Only one class may appear in a supertype list
Error:(16, 5) Kotlin: 'foo' overrides nothing
Error:(19, 40) Kotlin: Unresolved reference: SimpleInterface
Error:(54, 5) Kotlin: Unresolved reference: companion
Error:(55, 57) Kotlin: Too many arguments for public constructor ClassWithPrivateConstructor() defined in syntax.classesObjectsInterfaces.ClassWithPrivateConstructor
Error:(60, 33) Kotlin: Unresolved reference: newInstance
/home/martynas/sandbox/workshop-jb/src/ii_conventions/_11_Comparison_.kt
Error:(12, 13) Kotlin: Expecting a top level declaration
Error:(14, 1) Kotlin: Expecting a top level declaration
Error:(34, 32) Kotlin: Unexpected tokens (use ';' to separate expressions on the same line)
Error:(13, 5) Kotlin: Function 'compareTo' must have a body
Error:(13, 26) Kotlin: Unresolved reference: B
Error:(16, 14) Kotlin: Unresolved reference: B
Error:(16, 21) Kotlin: Unresolved reference: B
Error:(34, 20) Kotlin: Unresolved reference: date
Warning:(37, 12) Kotlin: Parameter 'date1' is never used
Warning:(37, 27) Kotlin: Parameter 'date2' is never used
/home/martynas/sandbox/workshop-jb/src/ii_conventions/_15_OperatorsOverloading.kt
Error:(16, 13) Kotlin: Expecting a top level declaration
Error:(20, 1) Kotlin: Expecting a top level declaration
Error:(40, 32) Kotlin: Unexpected tokens (use ';' to separate expressions on the same line)
Error:(17, 5) Kotlin: Function 'plus' must have a body
Error:(17, 17) Kotlin: Unresolved reference: A
Error:(17, 21) Kotlin: Unresolved reference: A
Error:(18, 5) Kotlin: Function 'times' must have a body
Error:(18, 18) Kotlin: Unresolved reference: A
Error:(18, 22) Kotlin: Unresolved reference: A
Error:(19, 5) Kotlin: Function 'not' must have a body
Error:(19, 16) Kotlin: Unresolved reference: A
Error:(22, 13) Kotlin: Unresolved reference: A
Error:(22, 20) Kotlin: Unresolved reference: A
Error:(40, 20) Kotlin: Unresolved reference: date
Error:(41, 9) Kotlin: Unresolved reference: date
Error:(41, 31) Kotlin: Unresolved reference: timeInterval
Warning:(44, 14) Kotlin: Parameter 'today' is never used
Warning:(49, 14) Kotlin: Parameter 'today' is never used
/home/martynas/sandbox/workshop-jb/src/ii_conventions/_12_ForLoop.kt
Error:(24, 24) Kotlin: To specify a type of a parameter or a return type, use the full notation: {(parameter : Type) : ReturnType -> ...}
Error:(24, 33) Kotlin: Expecting parameter name
Error:(24, 20) Kotlin: Cannot infer a type for this parameter. To specify it explicitly use the {(p : Type) -> ...} notation
Warning:(27, 26) Kotlin: Parameter 'firstDate' is never used
Warning:(27, 45) Kotlin: Parameter 'secondDate' is never used
Warning:(27, 65) Kotlin: Parameter 'handler' is never used
/home/martynas/sandbox/workshop-jb/src/ii_conventions/MyDate.kt
Error:(6, 8) Kotlin: Expecting an enum entry or member declaration
Error:(7, 9) Kotlin: Expecting an enum entry or member declaration
/home/martynas/sandbox/workshop-jb/src/ii_conventions/_14_InRange.kt
Error:(5, 24) Kotlin: Expecting a top level declaration
Error:(7, 1) Kotlin: Expecting a top level declaration
Error:(35, 25) Kotlin: To specify a type of a parameter or a return type, use the full notation: {(parameter : Type) : ReturnType -> ...}
Error:(35, 38) Kotlin: Expecting parameter name
Error:(6, 5) Kotlin: Function 'contains' must have a body
Error:(6, 27) Kotlin: Unresolved reference: E
Error:(9, 29) Kotlin: Unresolved reference: Container
Error:(35, 20) Kotlin: Cannot infer a type for this parameter. To specify it explicitly use the {(p : Type) -> ...} notation
Warning:(38, 18) Kotlin: Parameter 'date' is never used
Warning:(38, 32) Kotlin: Parameter 'first' is never used
Warning:(38, 47) Kotlin: Parameter 'last' is never used
/home/martynas/sandbox/workshop-jb/src/ii_conventions/_17_Invoke_.kt
Error:(5, 14) Kotlin: Expecting a top level declaration
Error:(7, 1) Kotlin: Expecting a top level declaration
Error:(41, 29) Kotlin: To specify a type of a parameter or a return type, use the full notation: {(parameter : Type) : ReturnType -> ...}
Error:(41, 41) Kotlin: Expecting parameter name
Error:(6, 5) Kotlin: Function 'invoke' must have a body
Error:(10, 34) Kotlin: Unresolved reference: My
Error:(41, 20) Kotlin: Cannot infer a type for this parameter. To specify it explicitly use the {(p : Type) -> ...} notation
Warning:(43, 12) Kotlin: Parameter 'invokable' is never used
/home/martynas/sandbox/workshop-jb/src/ii_conventions/_13_RangeTo.kt
Error:(20, 24) Kotlin: To specify a type of a parameter or a return type, use the full notation: {(parameter : Type) : ReturnType -> ...}
Error:(20, 33) Kotlin: Expecting parameter name
Error:(20, 20) Kotlin: Cannot infer a type for this parameter. To specify it explicitly use the {(p : Type) -> ...} notation
Warning:(23, 27) Kotlin: Parameter 'firstDate' is never used
Warning:(23, 46) Kotlin: Parameter 'secondDate' is never used
Warning:(23, 66) Kotlin: Parameter 'handler' is never used
/home/martynas/sandbox/workshop-jb/src/iii_properties/_21_DelegatesHowItWorks.kt
Error:(18, 24) Kotlin: To specify a type of a parameter or a return type, use the full notation: {(parameter : Type) : ReturnType -> ...}
Error:(18, 33) Kotlin: Expecting parameter name
Error:(18, 20) Kotlin: Cannot infer a type for this parameter. To specify it explicitly use the {(p : Type) -> ...} notation
/home/martynas/sandbox/workshop-jb/src/i_introduction/_9_Extensions_On_Collections/ExtensionsOnCollections.kt
Error:(51, 21) Kotlin: To specify a type of a parameter or a return type, use the full notation: {(parameter : Type) : ReturnType -> ...}
Error:(51, 42) Kotlin: Expecting parameter name
Error:(51, 20) Kotlin: Cannot infer a type for this parameter. To specify it explicitly use the {(p : Type) -> ...} notation
Warning:(57, 9) Kotlin: Variable 'maximumSizeOfGroup' is never used
/home/martynas/sandbox/workshop-jb/src/i_introduction/_5_Nullable_Types/NullableTypes.kt
Error:(73, 18) Kotlin: Expecting a top level declaration
Error:(75, 1) Kotlin: Expecting a top level declaration
Warning:(7, 9) Kotlin: Variable 's' is never used
Warning:(8, 9) Kotlin: Variable 'q' is never used
Warning:(10, 28) Kotlin: Parameter 'i' is never used
Error:(55, 58) Kotlin: Unresolved reference: Mailer
Error:(65, 52) Kotlin: Unresolved reference: Mailer
Error:(74, 5) Kotlin: Function 'sendMessage' must have a body
/home/martynas/sandbox/workshop-jb/src/i_introduction/_2_Default_And_Named_Params/DefaultAndNamedParamsUsage.kt
Error:(12, 30) Kotlin: To specify a type of a parameter or a return type, use the full notation: {(parameter : Type) : ReturnType -> ...}
Error:(12, 48) Kotlin: Expecting parameter name
Error:(12, 20) Kotlin: Cannot infer a type for this parameter. To specify it explicitly use the {(p : Type) -> ...} notation
Warning:(14, 13) Kotlin: Parameter 'collection' is never used
Warning:(16, 5) Kotlin: Unreachable code
/home/martynas/sandbox/workshop-jb/src/i_introduction/_2_Default_And_Named_Params/DefaultAndNamedParams.kt
Error:(19, 24) Kotlin: To specify a type of a parameter or a return type, use the full notation: {(parameter : Type) : ReturnType -> ...}
Error:(19, 33) Kotlin: Expecting parameter name
Warning:(6, 9) Kotlin: Parameter 'i' is never used
Warning:(6, 17) Kotlin: Parameter 's' is never used
Warning:(6, 33) Kotlin: Parameter 'b' is never used
Error:(19, 20) Kotlin: Cannot infer a type for this parameter. To specify it explicitly use the {(p : Type) -> ...} notation
Warning:(21, 9) Kotlin: Parameter 'name' is never used
/home/martynas/sandbox/workshop-jb/src/i_introduction/_3_Lambdas/Lambdas.kt
Error:(8, 23) Kotlin: Unexpected tokens (use ';' to separate expressions on the same line)
Error:(8, 17) Kotlin: Unresolved reference: x
Warning:(10, 9) Kotlin: Variable 'three' is never used
Error:(10, 21) Kotlin: Too many arguments for public abstract fun invoke(): kotlin.Int defined in kotlin.Function0
Error:(10, 24) Kotlin: Too many arguments for public abstract fun invoke(): kotlin.Int defined in kotlin.Function0
Error:(20, 29) Kotlin: Type mismatch: inferred type is () -> kotlin.Int but (kotlin.Int, kotlin.Int) -> kotlin.Int was expected
/home/martynas/sandbox/workshop-jb/src/util/questions/Question.kt
Error:(4, 6) Kotlin: Expecting an enum entry or member declaration
Error:(4, 9) Kotlin: Expecting an enum entry or member declaration
/home/martynas/sandbox/workshop-jb/src/i_introduction/_10_Object_Expressions/ObjectExpressions.kt
Warning:(17, 9) Kotlin: Variable 'foo' is never used
Warning:(42, 9) Kotlin: Variable 'mouseClicks' is never used
Warning:(43, 16) Kotlin: Unreachable code
Warning:(44, 5) Kotlin: Unreachable code
/home/martynas/sandbox/workshop-jb/src/i_introduction/_6_Smart_Casts/SmartCasts.kt
Warning:(11, 19) Kotlin: No cast needed. You can use ':' if you need a cast to a super type
/home/martynas/sandbox/workshop-jb/src/ii_conventions/_16_MultiAssignment.kt
Warning:(6, 10) Kotlin: Variable 'first' is never used
Warning:(6, 17) Kotlin: Variable 'second' is never used
Warning:(16, 14) Kotlin: Variable 'i' is never used
Warning:(16, 17) Kotlin: Variable 's' is never used
Warning:(21, 13) Kotlin: Variable 'i' is never used
Warning:(22, 13) Kotlin: Variable 's' is never used
Warning:(40, 17) Kotlin: Variable 'i' is never used
Warning:(41, 17) Kotlin: Variable 's' is never used
Warning:(52, 10) Kotlin: Variable 'year' is never used
Warning:(52, 16) Kotlin: Variable 'month' is never used
Warning:(52, 23) Kotlin: Variable 'dayOfMonth' is never used
/home/martynas/sandbox/workshop-jb/src/iii_properties/_18_Properties_.kt
Warning:(8, 9) Kotlin: Variable 'i' is never used
Warning:(13, 9) Kotlin: Variable 'j' is assigned but never accessed
Warning:(14, 9) Kotlin: The value '1765' assigned to 'var j: kotlin.Int defined in iii_properties.localVariables' is never used
/home/martynas/sandbox/workshop-jb/src/iv_builders/_22_ExtensionFunctionLiterals.kt
Warning:(27, 9) Kotlin: Variable 'lastChar2' is never used
/home/martynas/sandbox/workshop-jb/src/iv_builders/_25_HtmlBuilders.kt
Warning:(34, 17) Kotlin: Variable 'products' is never used
/home/martynas/sandbox/workshop-jb/src/iv_builders/_26_BuildersHowItWorks.kt
Warning:(27, 16) Kotlin: Unreachable code
/home/martynas/sandbox/workshop-jb/src/syntax/casts.kt
Warning:(5, 13) Kotlin: Variable 's' is never used
Warning:(5, 19) Kotlin: No cast needed. You can use ':' if you need a cast to a super type
Warning:(14, 9) Kotlin: Variable 'i' is never used
/home/martynas/sandbox/workshop-jb/src/syntax/ifWhenExpressions.kt
Warning:(4, 9) Kotlin: Variable 'max1' is never used
Warning:(6, 9) Kotlin: Variable 'max2' is never used
Warning:(17, 9) Kotlin: Variable 'result' is never used
Warning:(27, 18) Kotlin: The expression is unused
Warning:(28, 21) Kotlin: The expression is unused
Warning:(29, 23) Kotlin: The expression is unused
Warning:(30, 17) Kotlin: The expression is unused
Warning:(36, 20) Kotlin: The expression is unused
Warning:(37, 23) Kotlin: The expression is unused
Warning:(38, 17) Kotlin: The expression is unused
/home/martynas/sandbox/workshop-jb/src/syntax/javaCollections.kt
Warning:(6, 20) Kotlin: Parameter 'set' is never used
/home/martynas/sandbox/workshop-jb/src/syntax/numberConstants.kt
Warning:(4, 9) Kotlin: Variable 'float' is never used
Warning:(5, 9) Kotlin: Variable 'long' is never used
Warning:(6, 9) Kotlin: Variable 'char' is never used
/home/martynas/sandbox/workshop-jb/src/syntax/tryExpression.kt
Warning:(17, 9) Kotlin: Variable 'result' is never used
/home/martynas/sandbox/workshop-jb/src/syntax/varargsAndArrays.kt
Warning:(10, 9) Kotlin: Variable 'asc' is never used
Error:(12, 17) Kotlin: Unresolved reference: arrayOf
Error:(21, 18) Kotlin: Assignment operators ambiguity:
internal open fun <ERROR FUNCTION>(): [ERROR : <ERROR FUNCTION RETURN TYPE>] defined in root package
internal open fun <ERROR FUNCTION>(): [ERROR : <ERROR FUNCTION RETURN TYPE>] defined in root package
Warning:(33, 9) Kotlin: Variable 'intArray' is never used
Error:(33, 30) Kotlin: Unresolved reference: intArrayOf
/home/martynas/sandbox/workshop-jb/src/v_collections/A_Introduction_.kt
Warning:(16, 20) Kotlin: Parameter 'set' is never used
/home/martynas/sandbox/workshop-jb/src/v_collections/B_FilterMap.kt
Warning:(6, 9) Kotlin: Variable 'positiveNumbers' is never used
Warning:(8, 9) Kotlin: Variable 'squares' is never used
Warning:(16, 27) Kotlin: Parameter 'city' is never used
/home/martynas/sandbox/workshop-jb/src/v_collections/C_AllAnyAndOtherPredicates.kt
Warning:(7, 9) Kotlin: Variable 'hasZero' is never used
Warning:(9, 9) Kotlin: Variable 'allZeros' is never used
Warning:(11, 9) Kotlin: Variable 'numberOfZeros' is never used
Warning:(13, 9) Kotlin: Variable 'firstPositiveNumber' is never used
Warning:(16, 21) Kotlin: Parameter 'city' is never used
Warning:(21, 35) Kotlin: Parameter 'city' is never used
Warning:(26, 26) Kotlin: Parameter 'city' is never used
Warning:(31, 29) Kotlin: Parameter 'city' is never used
Warning:(36, 30) Kotlin: Parameter 'city' is never used
/home/martynas/sandbox/workshop-jb/src/v_collections/E_MaxMin.kt
Warning:(4, 9) Kotlin: Variable 'max' is never used
Warning:(5, 9) Kotlin: Variable 'longestString' is never used
/home/martynas/sandbox/workshop-jb/src/v_collections/G_Sum_.kt
Warning:(4, 9) Kotlin: Variable 'sum' is never used
/home/martynas/sandbox/workshop-jb/src/v_collections/K_CompoundTasks.kt
Warning:(3, 40) Kotlin: Parameter 'product' is never used
Warning:(14, 44) Kotlin: Parameter 'product' is never used
/home/martynas/sandbox/workshop-jb/src/vi_generics/_27_ErasedGenerics.kt
Warning:(46, 16) Kotlin: Unreachable code
Since the .idea
folder was removed the project no longer includes the Html Demo
run configuration references by _39_HtmlBuilders.kt
I'm a complete noob to Kotlin so I may be missing the point but the project doesn't build and currently errors in workshop-jb/src/ii_conventions/_15_OperatorsOverloading.kt
I opened the Koans project in IntelliJ but noticed that the build.gradle
file couldn't be parsed.
When clicking on the 'Refresh all Gradle projects' button in the 'Gradle Projects' menu I got the following message: 'Could not determine java version from '9.0.0.15''.
After upgrading Gradle to version 4.2.1 the problem went away and the contents of the build.gradle file were recognized correctly.
I found the solution here: https://discuss.gradle.org/t/could-not-determine-java-version-from-9-0-1/24457/3
PR: #114
There is inccorect TestShop.kt in Collections section on http://try.kotlinlang.org.
As a result some tasks cannot be passed: FlatMap, Sort, GroupBy and Compound tasks.
Problem: riku customer is not added to shop (it is added in file in this repository).
I am trying Kotlin M9 and I get a plugin version error. clicking on the error fixes it, but would be nicer to have it work out of the box.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.