#dev-general
1 messages ยท Page 85 of 1
https://paste.helpch.at/opepejotas.xml my dependency list
yeah
people say kotlin maven is a big pain in the ass but I haven't had a single problem with it yet
I use maven because I find it easier to read, but mostly because it's what I've been using for pretty much ever
You find 5 lines of XML easier to read than 1 string?
kinda yeah
it tells you the group id, artifact id, and version
Rest assured you'll be assimilated into the gradle masterrace soon
So does gradle's syntax lol
gradle does this: "groupId:artifactId:version"
I'm mainly using maven because it's what I'm used to though
not for long
maybe I'll learn gradle at some point
:)
if I find a need to switch to gradle I'll switch to gradle
I don't know how you can stand maven's speeds
yeah the build speed is a bitch
I find compilation after a tiny change takes 20-30 seconds
whereas gradle is almost instant
takes around two minutes just to shade all of these modules
so you're saying gradle is faster?
might have to look in to gradle then lol
Incremental compilation means tiny changes will compile almost instantly
wait, gradle or groovy?
this just a kotlin thing? afaik i havent saw this in another language before
doesn't gradle's syntax look like compile("", "", "")?
it's not exclusive to kotlin
or is that outdated now
that's with the DSL
@onyx loom that is a really useful Kotlin feature, probably in other languages though
the kotlin DSL that is - if you don't like groovy you can write gradle scripts in kotlin
sexy af being able to add numbers inside a print
Yeah string interp is in a few modern languages
kotlin is the most modern ๐
DSL is probably a bad idea
You can use it to create monstrosities as well, let me find the image just a sec
implementation 'groupId:artifactId:version'
The DSL is kinda personal preference
I don't really like it
but I think it has potential
^^ that's in groovy
There you go, the monstrosity you can create with it
one of the main reasons I switched to Kotlin though is it means I don't even have to touch J... cough cough J...cough cough sorry, I can't say it
@ocean quartz you disgust me
I know
imagine having to write getters and setters in your language
AAAAAHHHHHHH
@ocean quartz I wonder if you could write an entire plugin inside of a String
don't say that word
Sorry
lol
Typescript is ok tho
never used TypeScript
never used anything other than Java, very basic Python, Kotlin, even more basic C, a really really small amount of PHP, and maybe touched on C# a little bit
give a language review for TS
AAAAAAAHHHHHHH
lol
alright I think I should be good now
anyway
JS is all over the place though
I won't lie
I don't think js is that bad
if you use it for its intended purpose then it's fine
small scripts on webpages
yeah it is lightning fast
PHP takes a bit more time to load
though it's type inference is a joke
it's not even type inference
it's what is it called, duck typing?
Yeah I think so
"This" = true, "" = false
true + true = 2
that's where I draw the line
and then
we get to the libraries
cough cough https://www.reddit.com/r/webdev/comments/g80hbm/the_oneline_package_ispromise_broke_npm/ cough cough
As a language it's not that ugly, it does the job, it's reasonably fast, and interacts well with html
I agree with that
npm is a joke
the libraries are a joke though
Yes lmao
why would you even depend on a one-line package that would literally take me 5 seconds, if that, to write in myself
The amount of 1 line packages is ridiculous
node_modules is usually like 2gb
npm install is just an illusion of being productive while you wait for thousands of packages to download
let's do a test of how long this takes me to type
function isPromise(obj) {
return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
}
about 20-30 seconds, including the time it took me to read what was written in the post, and include the ```js
literally nothing
das crazy
what is the actual point in a one-line package?

just to be able to implement it in multiple packages?
than it does to type it
exactly
now that's a joke
can anyone here explain to me what angular is and how it works by the way?
is it an alternative to node?
I was thinking about this a couple hours ago
or just frontend websites as a whole
because my friend said he uses angular for frontend and Kotlin + Ktor for backend
is node.js backend?
Yes
so Ktor + Kotlin is a node alternative
and definitely a better one since it means if you're writing stuff in Java it all stays in one codebase
It's not so much of a node alternative as it is a backend solution
you can do full stack kotlin which is nice
and what I mean by that sentence is if you're writing stuff for java in Kotlin
Full stack Java is more difficult
like a plugin
Yeah
You could quite easily write backend in Kotlin/JVM, frontend in Kotlin/JS and share code between the two
Web applets ๐ญ
๐ญ ๐ญ
since I've learned all the things Kotlin can do I'm not writing another line of Java unless I have to ever again
too soon
also hold on
lmao
if I write an API in Kotlin can people use it if they're writing in Java?
since I've learned all the things Kotlin can do I'm not writing another line of Java unless I have to ever again
this is pretty much what everyone thinks
Yes
99% interop
good idea
yeah most of the time the question I'd be asking when learning Kotlin would be "WHY TF IS THIS NOT IN JAVA?!?!?!?!?!?!?!?!"
unless the code is written in allman style
this is such a circlejerk
but i agree lmao
the sheer amount of quality of life stuff compared to java is crazy
doesn't allman actually defeat the point of things like expression whatever they're calleds?
expression bodies that's the one
I thought everything had to be wrapped in curly brackets
Personally I would say expression bodies are an exception
and when I say seriously bad, just take a look at VoteParty's source
Allman looks a lot nicer inside the IDE imo
like on github it looks ugly as hell, but combined with intellij's highlighting and things it becomes a lot more expressive
it's kinda personal preference
lol
and if statements taking 4 lines to do one action instead of just one line
if statements without braces are a bad idea in any code style imo
if (condition)
{
return
}
down to if (condition) return
they can lead to some nasty bugs
especially since unreachable code is only a warning in kotlin
ye id brace ifs
I hate having to brace things
I made a habit of bracing every if, no matter how annoying
thing is though, my style is based off of literally the rest of my life: function, not form
I brace every if unless it's very small things like return or continue
if(player.bal < 10)
sendMessage("You're too poor")
doSomethingElse()
if you wanted to return here and didn't notice the lack of bracing
if(player.bal < 10)
sendMessage("You're too poor")
return
doSomethingElse()```
lack of braces can cause mistakes very easily
yeah fair point
thing is though, my style is based off of literally the rest of my life: function, not form
as I said though, ^^^^^
fair enough i guess
i'd advise adhering to an existing code style on any public project though
yeah but I'd be surprised if there's a code style that looks like mine
my style is based around compactness and efficiency (and that's efficiency meaning the time it takes me to write it, not how fast it runs), not readability
I'd say so long as you're consistant, and provide a style guide you're okay for the most part.
^
probably a good idea
consistency is key
I'm very inclined to say that readability should be prioritised over everything else
Well if you're using java, ideally yes. That's pretty much the point of the language
concise code doesn't mean it's good code, especially if you're sacrificing readability to get the concisity
If you want a functional language something like scala might be better
kOtLiN
Maybe, I haven't looked too much into kotlin
u wont regret it ๐
any language with first class functions is a step up from java lol
I want to though lol
dew it
is there way to add commented line in a Yaml with a FileConfiguration object ?
I'm assuming by the fact that comments aren't actually part of YAML (they're just skipped, they don't actually count) I'd probably say no
sadly not
snakeyaml completely ignores comments
and I don't believe you can set them
why would you want to write comments like that anyway?
hocon ๐ฅฐ
because I still can't extract a default config from my jar
so you've written the config file in to the correct folder right?
if you've written it you don't want to read from the embedded one you want to read from the one you just wrote
he can't use the embedded one
so imagine he's setting the defaults manually
i'm fairly sure there's a way to get this working, I just can't remember it
this was probably already answered but, why exactly can't he use the embedded one?
weird classloader stuff
resources from a classloader are never loaded in by papi
HOWEVER
i've had an idea @brave minnow
this is gonna be a disgusting hack
but it might just work
also can't he just save the resource himself directly?
actually I'm not getting this
that method we mentioned earlier only loads classes, nothing else
but then won't it load his class which then saves the file?
I'm saying if he didn't try and save a resource using is it PAPI's API? idk
ah okay
that's a bit stupid isn't it?
what's the fix?
I'm talking about the fix on PAPI's end, not on the expansion's end
if it's a simple fix I'll fork this right now, fix it, and submit a merge request
The simple fix would be to add the Jar's URL to the URLClassLoader rather than each individual entry like piggy's issue
but since most people will probably be on older versions
Time for a fat workaround
so what would need changing?
try (URLClassLoader cl = new URLClassLoader(new URL[]{jar}, clazz.getClassLoader()); JarInputStream jis = new JarInputStream(jar.openStream())) that line?
Yeah I think s
too late @prisma wave http://prntscr.com/splgby x)
So
hold on a second
@brave minnow this solution will support comments and won't need to do it in code
Uh oh
probably why he's using build path
@prisma wave It's done and honestly it is executed only when the config folder is empty so it's like saveDefault with extra steps ๐คท
you misspelt generateDefautlConfig() by the way @brave minnow
damn did they get rid of that faq meme
what FAQ meme?
that image used to in faq list
@jovial warren I found gold on a shit ... hold on a second ๐ http://prntscr.com/splhyt
I said they should replace Eclipse and IntelliJ with Java and Kotlin in that meme @onyx loom
I AM EXTREMELY CLEVER
white theme, my eyes
that's gonna make it massive since he's using build path
in maven you'd do <scope>provided</scope> and in gradle I can't remember what it is
that would stop it from bundling the spigot API in to your plugin
THEN WHY AREN'T YOU USING IT?!?!?!?!?!?!?! lol
as I said, i'm extremely clever
that should work for getting the file from the jar
too late I won't change that it's staying like this maybe in a future version ๐
also I think I'm probably gonna convert to gradle if it's definitely gonna be faster
@brave minnow your loss
@jovial warren because I don't know well how to use it lol
bad dev bingo:
- Uses eclipse
- Uses light theme
- Uses build path
we have a bingo!
well fuck off I decided to use your code you boy smarter than me ! รจ_รฉ angry upvote
yeah I didn't mean for it to come out that harsh
Gradle good, not gradle bad
@jovial warren
- making a plugin for fun
- not giving a shit because it's the beggining
- well I'm use intelliJ stop to bully me ๐ข
there is no excuse for using light theme
as I said, that came out a little more harsh than I intended
there is no excuse for using light theme
I definitely second that though
you made me angrily better รจ_<
you boys are fkin cool I like to deal with you !!! much agressivity is for love :p
๐
Bardy, no.
I definitely second that though
There is not.
wot
Dark theme, or no theme
oh yes, of course
that's exactly what I meant...?
no theme is like you coding on invisible IDE ? '-'
no
that's called using black theme with black text
u dont code at all
that's not dark theme
no theme is essentially what happens to websites when the CSS doesn't load in properly
No, no theme is deleting your IDE
true
no, no theme is getting rid of your screen
o
apparently 5.74 GB isn't enough for photoshop's scratch disk
and by the way, that's a 250GB SSD
and I just emptied the downloads
disk clean up too?
wtf bro my eclipse turned into red/blue/yellow/purple logo and it goes dark 
you didn't understand ๐
lol
if you're a student I'd recommend applying for the GitHub Student Developer Pack lol
gives you all JetBrains products for free
it gives you much more than just free IDE's though
o wow
for any high school/secondary school and above students who haven't applied for it, I highly recommend you apply for it
https://gyazo.com/4202f0e47b243567a13a959e29b63e36 also that might explain my storage issue a little bit
don't ask why my computer's in Spanish
Hey, I really hope there's someone who can help me out.
I'm currently messing around with uploading files via PHP (https://www.w3schools.com/php/php_file_upload.asp) and I'm trying to find out if there's a way I could randomize the name of the file it uploads.
Anyone who can help me?
don't know PHP sorry
there is no excuse for using light theme
@onyx loom ๐
please don't tell me you use light theme @heady birch
was gonna say
lol
NO
EXCUSE
oh god how do u use this niall
my eyes burn
i am sorry for anyone ive just traumatised
imagine not using material theme
hey my imports are orange ๐ฆ
orange text on light theme get out
i dont use light theme ๐ฆ
Cos you got the weird new theme
yeah I know
yall can do a code review while ur at it xd
use constants
farrenheight's type can be inferred
for the multipliers and things
This was before I knew the true power of kotlin
THEN LEARN KOTLIN
oh thank god
like me ๐
I nearly had a heart attack lol
@onyx loom const val FARENHEIGHT_MULTI = 0.555555555
const is a thing in Kotlin?
its using the same variable as celcius
@jovial warren I was student this year but it's finished lol
const val gets inlined
inline val?
i didnt really know how to optimise the calcs of farrenheight into celcius
im using 2 lines for the calcs 
inline val isn't exactly a thing
good point
there's probably a converter out there somewhere
also it's fahrenheit
not farrenheight
I agree
val inCelcius = (farenheit - 32) * 0.55555555
I personally call the better one Centigrade
but please use const val
https://tenor.com/Z4Di.gif @heady birch
Lol
ok ๐
Farenheight?
yeah
i have no fuckin clue
magic numbers bad
I personally use imperial measurements over metric
is me using BigDecimal good or bad?
idk
i heard kotlin has its own rounder
depends
see in most countries you're either full imperial (like the US), or full metric (like most of Europe), but in the UK, we like to do a bit of both
BigDecimal is still used, but it's not really necessary here
Double will do
@jovial warren only in height and distance
metric > everything
for example: the fuel that you put in your car is measured in litres (metric), but the consumption of that fuel is measured in miles per gallon (imperial)
ยฏ_(ใ)_/ยฏ
@prisma wave you are fundamentally wrong sir
I do use kotlin
For any new non-spring projects I will use kotlin
Until I learn kotlin and spring nicely
@prisma wave and how would i go about rounding to a certain d.p with double?
We should just use Metric everywhere
I agree we should just use one universal system, don't agree that should be metric though
the kotlin system soon โข๏ธ
@onyx loom iirc Double.round exists
Metric is the most consistent
true
there's just something about it that doesn't quite sit right in my head though
also Double.round isn't a method
unless it's not static
no it's either roundToInt() or roundToLong()
Yeah was gonna say it's roundToInt
ah ok
but does that truncate or actually round?
When I try to use FontAwesome on a webpage, why do the icons appear like this? I have it in my page because I have html <link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous"> in the head section. The two I'm trying to use are html <i class="fas fa-search"></i> <i class="fas fa-shopping-basket"></i>
@onyx loom rule with truncation is usually if it doesn't truncate explicitly it's rounding
@errant geyser sure the icons you're looking for are called search and shopping-basket?
yup
Coppied the basket code from here: https://fontawesome.com/icons/shopping-basket?style=solid
And the search one from here: https://fontawesome.com/icons/search?style=solid
sure the sha integrity is the same?
Copied from https://www.bootstrapcdn.com/fontawesome/ so yeah
Web interface? You mean browser? I've tried Chrome and the new Edge beta
you just using bootstrap?
not browser, for example: angular, npm, etc.
Ah yeah just Bootstrap and its dependencies, so jQuery and popper.js too
I know it's a bit insecure, but have you tried it without the fingerprint?
didn't think that would do anything
https://paste.helpch.at/dilivahiji.coffeescript @prisma wave are u proud ๐
i did the cleanup thing
Looks like it is BM
BM?
KM*
old fashioned name
๐
yeah I know that @prisma wave was just wondering if he meant something else lol
@onyx loom a few things
variable names should be lowerCamelCase
farrenheight could be inferred (ie without the :Double)
the magic numbers (32 and 5/9) should be extracted to constants
@onyx loom why tf does the bin see it as coffeescript lol
and also fix your god damn spelling
the detection algorithm isn't perfect
"farrenheight" -> "fahrenheit"
I DONT CARE
ITS AN INFERIOR SYSTEM
i will not change its spelling, as it represents how shit it is
and "celcius" -> "celsius"
also, making that better depends on scalability and readability
if you want to use that conversion in more than just one place I'd suggest using a constant
why is using constants better?
i had to google that.
also hold on
scalable yes. using magic numbers is bad because there's no implication on what the number is actually for, so it's less readable
val farrenheight: Double = reader.nextDouble()
also hold on
println("Celsius: $celsiusfinal degrees") can be replaced with is it printf("Celsius: %.1f degrees", celsiusfinal)?
which takes out the need for an extra variable
o.o
I think that's the method?
ill try it, ty
actually I don't think printf() is a method in Kotlin
System.out.printf() still works though
actually hold on
println("Celsius: ${String.format("%.1f", inCelsius)} degrees") should work
probably a better way to do that though
your welcome
"%.1f".format(inCelsius) can also be done iirc
Wha
There is always a way to make things smaller
^^^^
println("Celsius %.1f degrees".format(inCelsius))
https://paste.helpch.at/dilivahiji.coffeescript @ocean quartz here's the code we're working on by the way
println("Celsius %.1f degrees".format(inCelsius))
that's even better
just please surround it with `` lol
gods
fair enough
Its so awkwardly placed
what kinda phone you got?
Moto OP
ye its on 2/2 for me too
same
wew
same with =
u could prob customise it
that's why you put two ` characters in then go back and put in the code
Its on sec,
But its like-> symbols-> page change -> char-> type msg-> same char stuff again
๐
Ah
Welp
that's why I use my PC to type a mere most of the time
Welp electricity just came back on rn
nice
@old wyvern
I have been sitting in darkness for 1.5 hours
Theres not time to wait! Ask your question @obtuse gale!
What ticket?
support i think
For?
I bought DeluxeQueues recently
Oh
We don't have a ticket system, just ask your question
and I have some problems
no ticket system
What if you do fun Double.inCelcius(): Double = (this - 32) * 5/9 then "Celsius %.1f degrees".format(farrenheight.inCelcius())?
Link your spigot and u get access to the specific channel I think
Only boosters can
Hey matt
Oh nice xD
that's better
lmao
#spigot-linking to verify DeluxeQueues then ull get access to the channel @obtuse gale
that one's from TSC by the way
Alright thanks
what's Deluxe Queues lol
glares plugins
ah okay
google /shrug
aren't all of glare's plugins open-source?
you basically pay for the support and to support the dev
yup
Queues ain't iirc
Where I can found my id of spigotmc?
Url
I already putted the discord in
ik guilds and VP is freemium
On your profile, it's the number after your name on the URL
also how tf did you manage to create a web GUI for LiteBans @frail glade
I'm not asking how you did it I'm asking how you put up with the API
thanks !
https://www.spigotmc.org/resources/litebans-material-ui.46648/ also that image at the top isn't dark theme compatible smh
That's a fork of the original. I haven't updated it in a year or two since I fell out of web development.
Not sure if it still works.
ah okay
I already linked my id
I just found the original design boring so I put a twist on it and made it a kind of stand-aline site.
just curious though, have you seen LiteBans' API?
Not for a few years
trust me, it probably hasn't got any better
Nicoo, when did u buy DQ?
https://gitlab.com/ruany/LiteBansAPI
- Executing raw queries
- Requires you to execute said queries asynchronously
ull need to wait for the database to update then
oh and as an added bonus, tells you to execute commands using Bukkit.dispatchCommand()
database can only be updated by clip / cube iirc
somebody should pin LiteBans' API as an example of how not to make an API lol
if you can even call it that
Don't hate on Ruan. It still works.
"""API"""
@frail glade but it's the biggest nightmare to use ever
The website side wasn't too bad
Though I wouldn't write that in raw PHP ever again
I'd use something like vue butt that would be harder for people to host.
you write in Kotlin right?
I was watching some videos on Vue last night and it was pretty hawt, ngl.
I attempt to, at least.
if you want a web interface use Ktor
that isn't going to work for LiteBans though since it uses PHP
but just when you make your own ones use Ktor
you can literally embed the web server in to your plugin so it doesn't even require a separate web server
But I'm not invested enough in that
Idk how that got on the first page for most downloads
wait what?
It's the 9th most downloaded web resource on SpigotMC 

Last time I checked that resource it was like just barely hitting the front page
Now we top 10
LOL
basically it turns this:
fun example() {
return whatever
}
in to this: fun example() = whatever
I saw a lot of instances in vote party
smile
I can do some cleaning up if you want
I'm guessing Sxtanna is a big fan of the allman style
or is that you
one of the two
or both
ud have to get approved by sx by the sounds of it
yeah
that might be a little difficult
It's Sxtanna
because, y'know
true
that ^
It was one of the only reasons I could get him to contribute to the project
lol
is it you or him who's a fan of:
fun example()
{
// do something
}
a.k.a the allman style
Sx
imo it looks horrendous
Same
Yo what's the IJ shortcut to go to the uh
What's it called
Where a method is declared?
Made?
Ctrl + Click or Ctrl + Q
alt + f7?
i believe
Nope, thats find usages
POG
allman looks better imo but the expression body that u recommend dont look too bad either, but its too compact for me
nvm
Ctrl + Q is documentation
It's been that easy this whole time
Ctrl + Click is the one you're looking for
My life just got a whole lot better
Ctrl + Alt + O on your classes
and then Ctrl + Alt + L
O removes unused imports, L formats
i have noticed the high levels of shortcuts in this program.
yeah
theres quite the lot
@frail glade running Ctrl + Alt + L is gonna make it look better lol
there are hundreds
you can configure a code style to work with ctrl + alt + l
๐
This is so dumb, discord messages will scape \n on messages, so to use it I need to do body.replace("\\n", "\n") lmao
.\n.
also @frail glade it's your plugin, you're supposed to be the one who dictates what goes in to it?
I really don't know what I'm doing, so I do enjoy input from others.
yeah
if you don't want it written in a certain style though you can say you don't want it written in a certain style
I don't really care what it's written in. I just adapt to what I have in front of me.
fair enough
For example I just recoded a forge mod today and I had never touched forge before.
yeah
wew
Yeah. I just mess around with code until something works for the most part.
If it doesn't crash, I call it good.
exactly what everyone else does lol
and anyone who tells you they do otherwise is lying
Facts.
why does he use BukkitRunnable smh
internal fun Plugin.runTaskTimer(period: Long, task: BukkitRunnable.() -> Unit) {
object : BukkitRunnable() {
override fun run() {
task.invoke(this)
}
}.runTaskTimer(this, 0L, period)
}
BukkitRunnable was deprecated ages ago
or the methods using it were
Not really sure why it matters
the methods using it were weren't they
isn't it recommended to use Runnable instead now?
depends
actually there's another method
BukkitRunnable.scheduleTaskTimer exists iirc
BukkitRunnable can cancel itself
Runnable can't
ah okay
also apparently runTaskTimer isn't deprecated
public synchronized BukkitTask runTaskTimer(@NotNull Plugin plugin, long delay, long period) throws IllegalArgumentException, IllegalStateException {
checkNotYetScheduled();
return setupTask(Bukkit.getScheduler().runTaskTimer(plugin, (Runnable) this, delay, period));
}
at least, that one isn't
also can someone please explain to me what the point of using Kotlin is if you're writing in allman style?
You need to stop.
First dissing java, now allman, what's next the entire concept of programming?
dissing java is allowed when kotlin exists
^^^^
Sthu Kali

also can someone please explain to me what the point of using Kotlin is if you're writing in allman style?
that makes no sense
things like expression bodies can't be used if you write in allman style
they may be an exception, but they shouldn't be used all the time anyway
they should be used where applicable
just because you have all these conciseness features available, doesn't mean they should be used all of the time
they should be used where applicable
^^^^^
I wanna see how close to the conventions mine is
it's probably miles off
"As a general rule, avoid horizontal alignment of any kind. Renaming an identifier to a name with a different length should not affect the formatting of either the declaration or any of the usages." what does that mean?
tf is horizontal alignment?
&8&m----------
Hello
&8&m-------------
@ minecraft servers
thats what horizontal alignment sounds like but i aint got a clue
that's vertical alignment?
wait huh
idk
then uh
it looks vertical to me
|
|
| Hello
|
|
https://shkspr.mobi/blog/2014/11/why-i-vertically-align-my-code-and-you-should-too/ apparently that's vertical alignment
so I'm guessing horizontal alignment is the opposite?
yep
writing code like this:
var example = 1
var longerExample = 2
```?
@jovial warren I believe horizontal alignment is like kotlin when(value) { is_A_LongCondition -> blah() short -> blah2() else -> blah() }
artifically adding more spaces
yeah I hate when I see that
you know that article I linked actually recommended you do that
ew
yuck
also is it just me or does IntelliJ like to just add a random new line at the end of say a class code block
class Whatever {
}
// empty new line here
with an extra empty line
it does
Learn something new everyday
wait that's actually recommended?
thats interesting
actually I'm reading that wrong
it isn't recommended
it's recommended to end with a \n character

https://kotlinlang.org/docs/reference/coding-conventions.html?_ga=2.30215097.740388959.1590698238-208121748.1590698238#modifiers by standard apparently final is supposed to come before abstract
never seen that one before
actually I'm reading that wrong
nothing can be both abstract and final I'm just being dumb
looks liek it
yeah I know
Does Kotlin even have final?
Where would you use it? Classes?
I guess not?
yeah
public / protected / private / internal
expect / actual
final / open / abstract / sealed / const
external
override
lateinit
tailrec
vararg
suspend
inner
enum / annotation
companion
inline
infix
operator
data
that's a lot of key words
Quite a few there that I have never used
get is a keyword
for example kotlin abstract class Parent { abstract val age: Int } open class Child1 : Parent() { final override val age = 3 } class Child2 : Child1
annotation?
Ooh interesting ;o
infix sounds interesting as well
infix is cool
what does infix do?
you can invoke the function without parens or a .
ah okay
without infix it would be 1.to(5)
infix fun <A, B> A.to(other: B) : Pair<A, B>``` is the definition
that's like the most useful feature of Kotlin
the absence of ternary operators in Kotlin is a little bit of a disappointment but I imagine there's a valid reason for it
good point
This is pretty cool
(1..5).rand(5)
can't do you (1..5) rand 5?
step?
for(i in 1..10 step 2)```
yeah
in Java that would be for (int i = 1; i > 10; i += 2) I think
precisely
yuck
ofc
just had to make sure
i think the java is similar to visual basic for that, cant really remember tho
and the C
C is exactly the same
that's why it was kinda easy to learn
until I got to static declaring local variables
that's where I draw the line
or is it global variables
static local variable?
think so
๐ฎ
to quote geeksforgeeks: "a static variable remains in memory while the program is running. A normal or auto variable is destroyed when a function call where the variable was declared is over"
so basically static declares global variables
actually no
it allows you to declare a field inside of a function
what's that scope pollution
#include<stdio.h>
int fun() {
static int count = 0;
count++;
return count;
}
int main() {
printf("%d ", fun());
printf("%d ", fun());
return 0;
}
that's an example of how static works in C
the output of that by the way is 1 followed by 2
C is weird like that though
Oo
basically static stops the variable from being destroyed when a new instance of the function it was declared in is called
https://kotlinlang.org/docs/reference/idioms.htm this is very useful for anyone learning kotlin
#include <stdio.h>
int main() {
static int x;
int y;
printf("%d \n %d", x, y);
}
that one returns 0 for x and "some garbage value" for y
some garbage value?
to quote the source
๐ค
oh ty bm, ill keep it in mind ๐
np
I have failed, was playing around with infix to make something like val test = randBetween 5 and 10 but doesn't work like that xD
basically static variables initialise to 0 automatically
I have failed, was playing around with infix to make something like
val test = randBetween 5 and 10but doesn't work like that xD
you'd need something more likerandBetween(5 and 10)or something
Didn't work either, tried as well xD
infix has to be between 2 values
you'd need something more like
randBetween(5 and 10)or something
this should in theory work
although and already exists
for bitwise and
yeah
"Prefer using an expression body for functions with the body consisting of a single expression."
indeed
isn't the entirety of Kotlin built around fixing Java's problems?
that was the original purpose
yeah
java with less boilerplate but faster than groovy and scala
it's grown since then tho
has it achieved that?
absolutely
isn't scala another java-based language?
also isn't Kotlin built around conciseness then if it's purpose is to remove Java's boilerplate?
for example getters and setters are completely useless when you think about them
thinking intensifies
yeah
and if you need anything fancy that's what the get and set keywords are for
all they do is stop you editing the actual value
there's definitely a reason for it
can't remember what it is though
if you don't want the value edited you just make it a val

expression body not found