Kotlin code help

Hello I’m currently studying kotlin and currently stuck on this assignment; here is my code for reference and the prompt itself. As of now I keep getting an error with the message

Ran 64 tests. Stopped after finding 1 failure:

Testing getPronunciation(word: String = “aw”) failed: Solution returned: “ah-w” Submission returned: “aw”

submitted by /u/Own-Contribution2639
[link] [comments]

Continue ReadingKotlin code help


Dear Sirs, I started learning Kotlin and I love the language very much, but the job market in Egypt -my country- only asks for this language very little and if they ask for developers who have at least three years of experience and preferably more, I admire the modern technology that we offer Kotlin as web development and desktop and phone platforms Android and iOS, my question is do I shorten the distance and learn React because it is the most demanded in the market and then after that Learn Kotlin as a second language, Or begin with Kotlin directly, but as I said, the problem is that the demand for Kotlin is weak, in addition to the fact that most also require prior knowledge of the Java language, and I have no idea about Java, What can my friends do?

submitted by /u/Any_Communication361
[link] [comments]

Continue ReadingConfused

Trying to figure out the best way to get a POC done for some JS code in Kotlin Multiplatform

Hiyas good people of r/Kotlin. I’m a long-time dev, but I’m new to Kotlin. I’ve got a pretty simple JavaScript library that I want to make a small wrapper for in Android, iOS, and a Server. My research seemed to indicate that Kotlin Multiplatform was necessary for interpreting JS in Kotlin so I made a new project. I’ve built the server jar, but when I try to run it I get an error:

Error: Unable to initialize main class org.package.ApplicationKt Caused by: java.lang.NoClassDefFoundError: io/ktor/server/application/Application 

Some googling suggests using -classpath with the java command to point to the correct path, but no one seems to say the path to what. I’ve tried paths to *.class and *.jar and neither work so I’m a little stuck.

If you can help with the above, that’s great, but the real reason I’m here is to ask the bigger question of whether I’m trying to do the right thing or not. I was hoping it would be a little easier to just get a small server going so I’m wondering if I’m going about it the wrong way. I did try a Quarkus server, and that worked real easily, but then I couldn’t figure out how to get it to interpret JS.

Anyways, this is too long already. If you read this far thanks, and if you know of an example project I could check out or something that runs JS through Kotlin in a server, I’d be much obliged. Thanks!

submitted by /u/CurvatureTensor
[link] [comments]

Continue ReadingTrying to figure out the best way to get a POC done for some JS code in Kotlin Multiplatform

Consistency vs Complexity – Going spare in the final bowling frame

There comes a point in most codebases where we are forced to choose between consistency and complexity. Do we double down on the existing way of doing things or make a special case to simplify some new feature?

Our 10 pin bowling simulator is an experiment in type-driven design and making illegal states unrepresentable. When faced with what to do with the special cases in scoring the final frame, we have to make a choice between the consistent complexity of adding more types, or simply adding behaviour to our existing types.

In this case I chose consistency, meaning that we gain several new frame types. By the end I think that we are functionally complete, but need one more pass through the code to see if anything simpler is trying to get out.

In this episode

  • 00:00:58 Change the tests one logical case at a time
  • 00:02:06 Add functionality by adding an UnplayedFinalFrame type
  • 00:03:52 Instantiate UnplayedFinalFrame in the right place
  • 00:05:34 Add InProgressFinalFrame
  • 00:10:13 FinalFrame spares
  • 00:12:12 Add BonusInProgressFinalFrame
  • 00:16:08 Add BonusCompletedFinalFrame
  • 00:19:28 Check in
  • 00:19:43 It turns out I was wrong about final frame scoring
  • 00:21:05 Check in the correction
  • 00:21:15 A test for a final frame strikes
  • 00:22:09 Our Strike scoring was wrong all along
  • 00:30:28 Commit our working scoring
  • 00:30:39 Review

You can see the code on GitHub https://github.com/dmcg/bowling-for-youtube and this miniseries in a playlist https://www.youtube.com/playlist?list=PL1ssMPpyqocjSQbAigPgMpDzLMxMc7kSv

submitted by /u/dmcg
[link] [comments]

Continue ReadingConsistency vs Complexity – Going spare in the final bowling frame

Kotlin Builder Library

Hi all, First, let me say that I think the Builder pattern is pretty much unnecessary in pure Kotlin apps. Data classes with default values and pass by name pretty much do the job.

However, one sticking point in migrating Java apps to Kotlin, you kinda need a builder-since Java doesn’t support pass by name. The Lombok builder annotation is pretty dodgy with Kotlin.

Are there other libraries I can use?

submitted by /u/k2718
[link] [comments]

Continue ReadingKotlin Builder Library

Android Dependency Hell

Is it just me? Every time I try to use a library the project breaks in my hands. A is compatible with B but B is not compatible with C. Upgrade, Downgrade, Sidegrade, google search for clues.

There must be a better way of getting matching libraries but I keep wasting hours every time I try to set up a new project.

Any help or suggestions are appreciated.



submitted by /u/SnooSongs5410
[link] [comments]

Continue ReadingAndroid Dependency Hell

Strict mode for concurrency

Is there a Kotlin equivalent for Swift’s strict concurrency checking, which basically shows an error or a warning whenever there is a chance for race-conditions to occur?

I found it useful when I was learning Swift and was wondering, if there is a similar thing for Kotlin. I know of the ways I can make my classes thread-safe, but I would like to have the compiler complain when I have missed something.

submitted by /u/Longjumping-Bee9576
[link] [comments]

Continue ReadingStrict mode for concurrency

Having issues with compose Multiplatform state management

I wrote a compose multiplatform composables by having each composable manage the local state such as an edit field and then saving the finished change before closing the edit field and rendering with text.

It seems that the composables are reusing the same mutableStateOf container for all iterations as I can change the enclosing composable parameters and they render with the same mutableStateOf.

Do I need to hoist all state of composables to top level and ensure that data is invalidated as the editing location changes?

Specifically, I am currently targeting only jvm and could hoist the state into the main function.

TLDR: I am lost in terms of properly handling state in compose multiplatform and my current understanding and implementation of local state mutation doesn’t seem to work.

Side Note: This is a local app and currently does not have a server portion. It is meant to be standalone and maybe in the future will save state to a server or maybe another instance of the app.

Also, if anyone has a good source for only compose multiplatform documentation, it would be very helpful. Reading Android jetpack compose and diffing against what is possible in compose multiplatform is confusing

Thanks for reading and any help

submitted by /u/TheRedPepper
[link] [comments]

Continue ReadingHaving issues with compose Multiplatform state management

End of content

No more pages to load