Tesseract. Recognizing Errors in Recognition SoftwareAndrey Karpov
Tesseract is a free software program for text recognition developed by Google. According to the project description, "Tesseract is probably the most accurate open source OCR engine available". And what if we try to catch some bugs there with the help of the CppCat analyzer?
Tesseract. Recognizing Errors in Recognition SoftwareAndrey Karpov
Tesseract is a free software program for text recognition developed by Google. According to the project description, "Tesseract is probably the most accurate open source OCR engine available". And what if we try to catch some bugs there with the help of the CppCat analyzer?
Go 1.10 Release Party, featuring what's new in Go 1.10 and a few deep dives into how Go works.
Presented at the PDX Go Meetup on April 24th, 2018.
https://www.meetup.com/PDX-Go/events/248938586/
Shapeless- Generic programming for ScalaKnoldus Inc.
"Introduction to Shapeless- Generic programming for Scala !". Broadly speaking, shapeless is about programming with types. Doing things at compile-time that would more commonly be done at runtime to ensure type-safety. A long list of features provided by Shapeless are explained in the enclosed presentation.
Checking the Code of LDAP-Server ReOpenLDAP on Our Readers' RequestPVS-Studio
In this article, I'd like to talk about the analysis of ReOpenLDAP project. It was developed to help solve issues that PAO (PJSC) MegaFon, Russia's largest mobile network operator, was faced with when employing OpenLDAP in their infrastructure. ReOpenLDAP is now successfully used in MegaFon affiliates all over Russia, so we thought it would be interesting to check such a high-load project as this one with our static analyzer PVS-Studio.
In May 2016, German game-development company Crytek made the, decision to upload the source code of their game engine, 'CryEngine V' to GitHub. The project is in active development, which leads to a large number of errors in the code. We have already checked the project with PVS-Studio for Windows, and now we can also analyze it using PVS-Studio for Linux. There was enough material for an article with the description of only crucial errors.
Media Portal 2 is open software of a media center class, allowing the user to listen to music, watch videos, viewing pictures, and much more. For us, the developers of PVS-Studio static analyzer, this is another chance to check an interesting project, tell people (and developers) about the errors we find, and demonstrate the abilities of our analyzer of course.
Every now and then, we have to write articles about how we've checked another fresh version of some compiler. That's not really much fun. However, as practice shows, if we stop doing that for a while, folks start doubting whether PVS-Studio is worth its title of a good catcher of bugs and vulnerabilities. What if the new compiler can do that too? Sure, compilers evolve, but so does PVS-Studio – and it proves, again and again, its ability to catch bugs even in high-quality projects such as compilers.
An introductory PowerPoint to understanding and applying the C++ programming language. Broken down into lessons covering:
Introduction: Definitions and the History of Programming
Lesson 1: Libraries, Variables and Types, Blocks and Namespaces, Functions
Lesson 2: If...Else Statements, For and While Loops, Scope
Exercise: Program a Gumball Game
Lesson 3: Classes and Objects, Pointers
Dusting the globe: analysis of NASA World Wind projectPVS-Studio
Sometimes it is useful to look back to see how helpful the analyzer was to old projects, and which errors can be avoided in good time, if the analyzer is regularly used. This time our choice was NASA World Wind project, which was being developed on C# until 2007.
ReactOS is intensively developing, and its codebase is steadily growing in size. On February 16, 2016, a new version of the operating system was released, and we thought it was a good occasion to run it through our static analyzer one more time. The new scan was done with PVS-Studio, version 6.02.
A code kata in C# to help practice techniques for safely removing dependencies form legacy code and creating unit tests. Questions? Suggestions? Contact @dubmun.
Kotlin: A pragmatic language by JetBrainsJigar Gosar
A pragmatic language for JVM and Android.
Combines OO and functional features.
Focused on interoperability, safety, clarity, tooling support.
Open Source.
Works everywhere where Java works.
Key focus on interoperability and seamless support for mixed Java+Kotlin projects.
Go 1.10 Release Party, featuring what's new in Go 1.10 and a few deep dives into how Go works.
Presented at the PDX Go Meetup on April 24th, 2018.
https://www.meetup.com/PDX-Go/events/248938586/
Shapeless- Generic programming for ScalaKnoldus Inc.
"Introduction to Shapeless- Generic programming for Scala !". Broadly speaking, shapeless is about programming with types. Doing things at compile-time that would more commonly be done at runtime to ensure type-safety. A long list of features provided by Shapeless are explained in the enclosed presentation.
Checking the Code of LDAP-Server ReOpenLDAP on Our Readers' RequestPVS-Studio
In this article, I'd like to talk about the analysis of ReOpenLDAP project. It was developed to help solve issues that PAO (PJSC) MegaFon, Russia's largest mobile network operator, was faced with when employing OpenLDAP in their infrastructure. ReOpenLDAP is now successfully used in MegaFon affiliates all over Russia, so we thought it would be interesting to check such a high-load project as this one with our static analyzer PVS-Studio.
In May 2016, German game-development company Crytek made the, decision to upload the source code of their game engine, 'CryEngine V' to GitHub. The project is in active development, which leads to a large number of errors in the code. We have already checked the project with PVS-Studio for Windows, and now we can also analyze it using PVS-Studio for Linux. There was enough material for an article with the description of only crucial errors.
Media Portal 2 is open software of a media center class, allowing the user to listen to music, watch videos, viewing pictures, and much more. For us, the developers of PVS-Studio static analyzer, this is another chance to check an interesting project, tell people (and developers) about the errors we find, and demonstrate the abilities of our analyzer of course.
Every now and then, we have to write articles about how we've checked another fresh version of some compiler. That's not really much fun. However, as practice shows, if we stop doing that for a while, folks start doubting whether PVS-Studio is worth its title of a good catcher of bugs and vulnerabilities. What if the new compiler can do that too? Sure, compilers evolve, but so does PVS-Studio – and it proves, again and again, its ability to catch bugs even in high-quality projects such as compilers.
An introductory PowerPoint to understanding and applying the C++ programming language. Broken down into lessons covering:
Introduction: Definitions and the History of Programming
Lesson 1: Libraries, Variables and Types, Blocks and Namespaces, Functions
Lesson 2: If...Else Statements, For and While Loops, Scope
Exercise: Program a Gumball Game
Lesson 3: Classes and Objects, Pointers
Dusting the globe: analysis of NASA World Wind projectPVS-Studio
Sometimes it is useful to look back to see how helpful the analyzer was to old projects, and which errors can be avoided in good time, if the analyzer is regularly used. This time our choice was NASA World Wind project, which was being developed on C# until 2007.
ReactOS is intensively developing, and its codebase is steadily growing in size. On February 16, 2016, a new version of the operating system was released, and we thought it was a good occasion to run it through our static analyzer one more time. The new scan was done with PVS-Studio, version 6.02.
A code kata in C# to help practice techniques for safely removing dependencies form legacy code and creating unit tests. Questions? Suggestions? Contact @dubmun.
Kotlin: A pragmatic language by JetBrainsJigar Gosar
A pragmatic language for JVM and Android.
Combines OO and functional features.
Focused on interoperability, safety, clarity, tooling support.
Open Source.
Works everywhere where Java works.
Key focus on interoperability and seamless support for mixed Java+Kotlin projects.
Slides from my "Swift, Swiftly" session at Øredev 2014.
Revealed by Apple in June of this year, the Swift programming language has already established itself as a huge leap forward for iOS and OS X developers. Learn the ins and outs of this new language, see how it compares to other modern OO languages, and hear about how Apple developers are using Swift to achieve new levels of productivity and efficiency.
Full video available: http://oredev.org/2014/sessions/swift-swiftly
Sometimes you see code that is perfectly OK according to the definition of the language, but which is flawed because it breaks too many established idioms and conventions. On the other hand, a solid piece of code is something that looks like it is written by an experienced person who cares about professionalism in programming.
A presentation at Norwegian Developer Conference 2010
Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...apidays
Apidays Paris 2023 - Software and APIs for Smart, Sustainable and Sovereign Societies
December 6, 7 & 8, 2023
Forget TypeScript, Choose Rust to build Robust, Fast and Cheap APIs
Zacaria Chtatar, Backend Software Engineer at HaveSomeCode
------
Check out our conferences at https://www.apidays.global/
Do you want to sponsor or talk at one of our conferences?
https://apidays.typeform.com/to/ILJeAaV8
Learn more on APIscene, the global media made by the community for the community:
https://www.apiscene.io
Explore the API ecosystem with the API Landscape:
https://apilandscape.apiscene.io/
The PVS-Studio team is now actively developing a static analyzer for C# code. The first version is expected by the end of 2015. And for now my task is to write a few articles to attract C# programmers' attention to our tool in advance. I've got an updated installer today, so we can now install PVS-Studio with C#-support enabled and even analyze some source code. Without further hesitation, I decided to scan whichever program I had at hand. This happened to be the Umbraco project. Of course we can't expect too much of the current version of the analyzer, but its functionality has been enough to allow me to write this small article.
Of complicacy of programming, or won't C# save us?PVS-Studio
Programming is hard. I hope no one would argue that. But the topic of new programming languages, or more exactly, search of a "silver bullet" is always highly popular with software developers. The most "trendy" topic currently is superiority of one programming language over the other. For instance, C# is "cooler" than C++. Although holy wars are not the reason why I'm writing this post, still it is a "sore subject" for me. Oh, come on, C#/lisp/F#/Haskell/... won't let you write a smart application that would interact with the outer world and that's all. All the elegance will disappear as soon as you decide to write some real soft and not a sample "in itself".
Video and slides synchronized, mp3 and slide download available at URL http://bit.ly/254wkpw.
Aaron Bedra focuses on describing a system as a series of models that can be used to systematically and automatically generate input data and ensure that a code is behaving as expected. Bedra discusses property based testing and how it can help one build more resilient systems and even reduce the time needed to maintain a test suite. Filmed at qconlondon.com.
Aaron Bedra is Chief Security Officer at eligible.com. He is the creator of Repsheet, an open source threat intelligence framework. Bedra is the co-author of Programming Clojure, 2nd Edition and a frequent contributor to open source software.
Listen to the keynote address and hear about the latest developments from Rachana Ananthakrishnan and Ian Foster who review the updates to the Globus Platform and Service, and the relevance of Globus to the scientific community as an automation platform to accelerate scientific discovery.
Code reviews are vital for ensuring good code quality. They serve as one of our last lines of defense against bugs and subpar code reaching production.
Yet, they often turn into annoying tasks riddled with frustration, hostility, unclear feedback and lack of standards. How can we improve this crucial process?
In this session we will cover:
- The Art of Effective Code Reviews
- Streamlining the Review Process
- Elevating Reviews with Automated Tools
By the end of this presentation, you'll have the knowledge on how to organize and improve your code review proces
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar
The European Union Agency for Law Enforcement Cooperation (Europol) has suffered an alleged data breach after a notorious threat actor claimed to have exfiltrated data from its systems. Infamous data leaker IntelBroker posted on the even more infamous BreachForums hacking forum, saying that Europol suffered a data breach this month.
The alleged breach affected Europol agencies CCSE, EC3, Europol Platform for Experts, Law Enforcement Forum, and SIRIUS. Infiltration of these entities can disrupt ongoing investigations and compromise sensitive intelligence shared among international law enforcement agencies.
However, this is neither the first nor the last activity of IntekBroker. We have compiled for you what happened in the last few days. To track such hacker activities on dark web sources like hacker forums, private Telegram channels, and other hidden platforms where cyber threats often originate, you can check SOCRadar’s Dark Web News.
Stay Informed on Threat Actors’ Activity on the Dark Web with SOCRadar!
Understanding Globus Data Transfers with NetSageGlobus
NetSage is an open privacy-aware network measurement, analysis, and visualization service designed to help end-users visualize and reason about large data transfers. NetSage traditionally has used a combination of passive measurements, including SNMP and flow data, as well as active measurements, mainly perfSONAR, to provide longitudinal network performance data visualization. It has been deployed by dozens of networks world wide, and is supported domestically by the Engagement and Performance Operations Center (EPOC), NSF #2328479. We have recently expanded the NetSage data sources to include logs for Globus data transfers, following the same privacy-preserving approach as for Flow data. Using the logs for the Texas Advanced Computing Center (TACC) as an example, this talk will walk through several different example use cases that NetSage can answer, including: Who is using Globus to share data with my institution, and what kind of performance are they able to achieve? How many transfers has Globus supported for us? Which sites are we sharing the most data with, and how is that changing over time? How is my site using Globus to move data internally, and what kind of performance do we see for those transfers? What percentage of data transfers at my institution used Globus, and how did the overall data transfer performance compare to the Globus users?
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTier1 app
Even though at surface level ‘java.lang.OutOfMemoryError’ appears as one single error; underlyingly there are 9 types of OutOfMemoryError. Each type of OutOfMemoryError has different causes, diagnosis approaches and solutions. This session equips you with the knowledge, tools, and techniques needed to troubleshoot and conquer OutOfMemoryError in all its forms, ensuring smoother, more efficient Java applications.
Experience our free, in-depth three-part Tendenci Platform Corporate Membership Management workshop series! In Session 1 on May 14th, 2024, we began with an Introduction and Setup, mastering the configuration of your Corporate Membership Module settings to establish membership types, applications, and more. Then, on May 16th, 2024, in Session 2, we focused on binding individual members to a Corporate Membership and Corporate Reps, teaching you how to add individual members and assign Corporate Representatives to manage dues, renewals, and associated members. Finally, on May 28th, 2024, in Session 3, we covered questions and concerns, addressing any queries or issues you may have.
For more Tendenci AMS events, check out www.tendenci.com/events
Quarkus Hidden and Forbidden ExtensionsMax Andersen
Quarkus has a vast extension ecosystem and is known for its subsonic and subatomic feature set. Some of these features are not as well known, and some extensions are less talked about, but that does not make them less interesting - quite the opposite.
Come join this talk to see some tips and tricks for using Quarkus and some of the lesser known features, extensions and development techniques.
Globus Connect Server Deep Dive - GlobusWorld 2024Globus
We explore the Globus Connect Server (GCS) architecture and experiment with advanced configuration options and use cases. This content is targeted at system administrators who are familiar with GCS and currently operate—or are planning to operate—broader deployments at their institution.
Advanced Flow Concepts Every Developer Should KnowPeter Caitens
Tim Combridge from Sensible Giraffe and Salesforce Ben presents some important tips that all developers should know when dealing with Flows in Salesforce.
Software Engineering, Software Consulting, Tech Lead.
Spring Boot, Spring Cloud, Spring Core, Spring JDBC, Spring Security,
Spring Transaction, Spring MVC,
Log4j, REST/SOAP WEB-SERVICES.
In software engineering, the right architecture is essential for robust, scalable platforms. Wix has undergone a pivotal shift from event sourcing to a CRUD-based model for its microservices. This talk will chart the course of this pivotal journey.
Event sourcing, which records state changes as immutable events, provided robust auditing and "time travel" debugging for Wix Stores' microservices. Despite its benefits, the complexity it introduced in state management slowed development. Wix responded by adopting a simpler, unified CRUD model. This talk will explore the challenges of event sourcing and the advantages of Wix's new "CRUD on steroids" approach, which streamlines API integration and domain event management while preserving data integrity and system resilience.
Participants will gain valuable insights into Wix's strategies for ensuring atomicity in database updates and event production, as well as caching, materialization, and performance optimization techniques within a distributed system.
Join us to discover how Wix has mastered the art of balancing simplicity and extensibility, and learn how the re-adoption of the modest CRUD has turbocharged their development velocity, resilience, and scalability in a high-growth environment.
top nidhi software solution freedownloadvrstrong314
This presentation emphasizes the importance of data security and legal compliance for Nidhi companies in India. It highlights how online Nidhi software solutions, like Vector Nidhi Software, offer advanced features tailored to these needs. Key aspects include encryption, access controls, and audit trails to ensure data security. The software complies with regulatory guidelines from the MCA and RBI and adheres to Nidhi Rules, 2014. With customizable, user-friendly interfaces and real-time features, these Nidhi software solutions enhance efficiency, support growth, and provide exceptional member services. The presentation concludes with contact information for further inquiries.
How Recreation Management Software Can Streamline Your Operations.pptxwottaspaceseo
Recreation management software streamlines operations by automating key tasks such as scheduling, registration, and payment processing, reducing manual workload and errors. It provides centralized management of facilities, classes, and events, ensuring efficient resource allocation and facility usage. The software offers user-friendly online portals for easy access to bookings and program information, enhancing customer experience. Real-time reporting and data analytics deliver insights into attendance and preferences, aiding in strategic decision-making. Additionally, effective communication tools keep participants and staff informed with timely updates. Overall, recreation management software enhances efficiency, improves service delivery, and boosts customer satisfaction.
We describe the deployment and use of Globus Compute for remote computation. This content is aimed at researchers who wish to compute on remote resources using a unified programming interface, as well as system administrators who will deploy and operate Globus Compute services on their research computing infrastructure.
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Globus
The Earth System Grid Federation (ESGF) is a global network of data servers that archives and distributes the planet’s largest collection of Earth system model output for thousands of climate and environmental scientists worldwide. Many of these petabyte-scale data archives are located in proximity to large high-performance computing (HPC) or cloud computing resources, but the primary workflow for data users consists of transferring data, and applying computations on a different system. As a part of the ESGF 2.0 US project (funded by the United States Department of Energy Office of Science), we developed pre-defined data workflows, which can be run on-demand, capable of applying many data reduction and data analysis to the large ESGF data archives, transferring only the resultant analysis (ex. visualizations, smaller data files). In this talk, we will showcase a few of these workflows, highlighting how Globus Flows can be used for petabyte-scale climate analysis.
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisGlobus
JASMIN is the UK’s high-performance data analysis platform for environmental science, operated by STFC on behalf of the UK Natural Environment Research Council (NERC). In addition to its role in hosting the CEDA Archive (NERC’s long-term repository for climate, atmospheric science & Earth observation data in the UK), JASMIN provides a collaborative platform to a community of around 2,000 scientists in the UK and beyond, providing nearly 400 environmental science projects with working space, compute resources and tools to facilitate their work. High-performance data transfer into and out of JASMIN has always been a key feature, with many scientists bringing model outputs from supercomputers elsewhere in the UK, to analyse against observational or other model data in the CEDA Archive. A growing number of JASMIN users are now realising the benefits of using the Globus service to provide reliable and efficient data movement and other tasks in this and other contexts. Further use cases involve long-distance (intercontinental) transfers to and from JASMIN, and collecting results from a mobile atmospheric radar system, pushing data to JASMIN via a lightweight Globus deployment. We provide details of how Globus fits into our current infrastructure, our experience of the recent migration to GCSv5.4, and of our interest in developing use of the wider ecosystem of Globus services for the benefit of our user community.
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Anthony Dahanne
Les Buildpacks existent depuis plus de 10 ans ! D’abord, ils étaient utilisés pour détecter et construire une application avant de la déployer sur certains PaaS. Ensuite, nous avons pu créer des images Docker (OCI) avec leur dernière génération, les Cloud Native Buildpacks (CNCF en incubation). Sont-ils une bonne alternative au Dockerfile ? Que sont les buildpacks Paketo ? Quelles communautés les soutiennent et comment ?
Venez le découvrir lors de cette session ignite
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...informapgpstrackings
Keep tabs on your field staff effortlessly with Informap Technology Centre LLC. Real-time tracking, task assignment, and smart features for efficient management. Request a live demo today!
For more details, visit us : https://informapuae.com/field-staff-tracking/
2. Contents
1. Introduction
2. How to start
3. Basics
a. Package & Import
b. Comments
c. Variables
d. Null Safety
e. Strings
f. Control Flow
i. If - Else
ii. For
iii. When
iv. While
g. Function
h. Higher-Order Functions & Lambda
4. OOP
a. Classes
b. Constructor
c. Properties
d. Methods
e. Inheritance
f. Interfaces
g. Data Classes
5. Ad Libitum
a. Any - Unit - Nothing
b. Let
c. Apply
d. With
e. Collections
i. listOf - mapOf - arrayOf
ii. Operators
f. Extensions
6. How to start
● Android Studio 2 Go to:
○ Preferences
○ Plugins
○ Click on Install JetBrains plugin
○ Install Kotlin Language
○ Restart
● Android Studio 3 ready out of the box.
7. buildscript {
repositories { jcenter() }
dependencies {
classpath "com.android.tools.build:gradle:2.3.3"
}
}
How to start
build.gradle
8. buildscript {
repositories { jcenter() }
dependencies {
classpath "com.android.tools.build:gradle:2.3.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:x.y.z"
}
}
How to start
build.gradle
10. apply plugin: "com.android.application"
apply plugin: "kotlin-android"
// If you're using annotation processor
apply plugin: "kotlin-kapt"
// A pro tip
apply plugin: "kotlin-android-extensions"
How to start
app/build.gradle
25. // This is an end-of-line comment
/* This is a block comment
on multiple lines. */
/* This is /* a nested comment
on multiple */ lines. */
Package & Import
Sample.kt
45. var message: String? = null
message.length // Error: Only safe or non-null asserted calls are
allowed on a nullable receiver of type String?
Null Safety
Sample.kt
49. var message: String? = null
message!!.length // Possible but don't do it unless you know what you’re doing
Null Safety
Sample.kt
50. var message: String? = null
if (message != null) {
message.length // It is ok. Spoiler: if syntax
}
Null Safety
Sample.kt
51. var message: String? = null
val messageLength = message?.length
println(messageLength) // Spoiler: Print a message to the standard output
Null Safety
Sample.kt
52. var message: String? = null
val messageLength: Int = message?.length
println(messageLength)
Null Safety
Sample.kt
53. var message: String? = null
val messageLength: Int = message?.length
// Error: Type mismatch: inferred type is Int? but Int was expected
Null Safety
Sample.kt
54. var message: String? = null
val messageLength: Int = message?.length ?: 0
println(messageLength)
Null Safety
Sample.kt
68. val a = random()
val b = random()
Control Flow - If else
Sample.kt
69. val a = random()
val b = random()
if (a > b) {
println("A is greater than b.")
}
Control Flow - If else
Sample.kt
70. val a = random()
val b = random()
if (a > b) {
println("A is greater than b.")
} else {
println("A is not greater than b.")
}
Control Flow - If else
Sample.kt
71. val a = random()
val b = random()
if (a > b) {
println("A is greater than b.")
} else if (a == b) {
println("A is equal to b.")
} else {
println("A is less than b.")
}
Control Flow - If else
Sample.kt
73. val message = "Hello World!"
for (character in message) {
println(character)
}
Control Flow - For
Sample.kt
74. for (number: Int in 0..10) {
println(number)
}
Control Flow - For
Sample.kt
75. for (number in 0..10) {
println(number)
}
Control Flow - For
Sample.kt
76. for (number in 0..10) {
println(number)
}
// Prints 0, 1, ..., 10
Control Flow - For
Sample.kt
77. for (number in 0 until 10) {
println(number)
}
Control Flow - For
Sample.kt
78. for (number in 0 until 10) {
println(number)
}
// Prints 0, 1, ..., 9
Control Flow - For
Sample.kt
79. for (number in 0..10 step 3) {
println(number)
}
Control Flow - For
Sample.kt
80. for (number in 0..10 step 3) {
println(number)
}
// Prints 0, 3, 6, 9
Control Flow - For
Sample.kt
81. for (number in 10 downTo 0) {
println(number)
}
Control Flow - For
Sample.kt
82. for (number in 10 downTo 0) {
println(number)
}
// Prints 10, 9, ..., 0
Control Flow - For
Sample.kt
83. val array: Array<String> = arrayOf<String>("Hello", "World!")
// Spoiler: How to create an array
Control Flow - For
Sample.kt
84. val array = arrayOf("Hello", "World!")
// Spoiler: How to create an array
Control Flow - For
Sample.kt
85. val array = arrayOf("Hello", "World!")
for (item: String in array) {
println(item)
}
Control Flow - For
Sample.kt
86. val array = arrayOf("Hello", "World!")
for (item in array) {
println(item)
}
Control Flow - For
Sample.kt
87. val array = arrayOf("Hello", "World!")
for (item in array) {
println(item)
}
// Prints Hello and World!
Control Flow - For
Sample.kt
88. val array = arrayOf("Hello", "World!")
for ((index, item) in array.withIndex()) { // Spoiler: Destructuring syntax
println("$index $item")
}
Control Flow - For
Sample.kt
89. val array = arrayOf("Hello", "World!")
for ((index, item) in array.withIndex()) {
println("$index $item")
}
// Prints 0 Hello and 1 World!
Control Flow - For
Sample.kt
91. val clumpsOfSugar = 0
when (clumpsOfSugar) {
0 -> println("The right way to drink coffee")
1 -> println("It is a sin, but I can ignore")
else -> {
println("Wait, $clumpsOfSugar clumps of sugar!?")
println("It is an unforgivable sin!!!")
}
}
Control Flow - When
Sample.kt
92. val clumpsOfSugar = 0
when (clumpsOfSugar) {
0 -> println("The right way to drink coffee")
1 -> println("It is a sin, but I can ignore")
else -> {
println("Wait, $clumpsOfSugar clumps of sugar!?")
println("It is an unforgivable sin!!!")
}
}
Control Flow - When
Sample.kt
93. val clumpsOfSugar = 0
when (clumpsOfSugar) {
0 -> println("The right way to drink coffee")
1, 2 -> println("It is a sin, but I can ignore")
else -> {
println("Wait, $clumpsOfSugar clumps of sugar!?")
println("It is an unforgivable sin!!!")
}
}
Control Flow - When
Sample.kt
94. val clumpsOfSugar = 0
when (clumpsOfSugar) {
0 -> println("The right way to drink coffee")
1, 2 -> println("It is a sin, but I can ignore")
in 3..5 -> println("Is it a kind of candy???")
else -> {
println("Wait, $clumpsOfSugar clumps of sugar!?")
println("It is an unforgivable sin!!!")
}
}
Control Flow - When
Sample.kt
95. val clumpsOfSugar = 0
when (clumpsOfSugar) {
0 -> println("The right way to drink coffee")
1, 2 -> println("It is a sin, but I can ignore")
!in 3..5 -> println("It is not 3, 4 or 5 :)")
else -> {
println("Wait, $clumpsOfSugar clumps of sugar!?")
println("It is an unforgivable sin!!!")
}
}
Control Flow - When
Sample.kt
96. val clumpsOfSugar = 0
val candyNumbers = arrayOf(3, 4, 5)
when (clumpsOfSugar) {
0 -> println("The right way to drink coffee")
1, 2 -> println("It is a sin, but I can ignore")
in candyNumbers -> println("Is it a kind of candy???")
else -> {
println("Wait, $clumpsOfSugar clumps of sugar!?")
println("It is an unforgivable sin!!!")
}
}
Control Flow - When
Sample.kt
97. val clumpsOfSugar = 0
when (clumpsOfSugar) {
0 -> println("The right way to drink coffee")
1, 2 -> println("It is a sin, but I can ignore")
randomInt() -> println("Are we still talking about coffee?")
else -> {
println("Wait, $clumpsOfSugar clumps of sugar!?")
println("It is an unforgivable sin!!!")
}
}
Control Flow - When
Sample.kt
98. val clumpsOfSugar = 0
when {
clumpsOfSugar % 2 == 1 -> println("An odd amount of sugar clumps")
clumpsOfSugar % 2 == 0 -> println("An even amount of sugar clumps")
else -> println("We have a really strange amount of sugar clumps")
}
Control Flow - When
Sample.kt
99. val clumpsOfSugar = 0
when {
clumpsOfSugar.isOdd() -> println("An odd amount of sugar clumps")
clumpsOfSugar.isEven() -> println("An even amount of sugar clumps")
else -> println("We have a really strange amount of sugar clumps")
}
Control Flow - When
Sample.kt
101. var clumpsOfSugar = 10
while (clumpsOfSugar > 0) {
clumpsOfSugar-- // yes we have -- and ++ syntax
}
println(clumpsOfSugar) // Prints 0
Control Flow - While
Sample.kt
102. var clumpsOfSugar = 10
do {
clumpsOfSugar--
} while (clumpsOfSugar > 0)
println(clumpsOfSugar) // Prints 0
Control Flow - While
Sample.kt
120. // Java on click listener
setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
// Do something
}
});
Higher-Order Functions & Lambda
Sample.kt
121. // Java 8 on click listener with lambda
setOnClickListener(view -> {
// Do something
});
Higher-Order Functions & Lambda
Sample.kt
122. // Kotlin on click listener with lambda
setOnClickListener {
// Do something
}
Higher-Order Functions & Lambda
Sample.kt
123. fun sum(a: Int, b: Int, callback: (Int) -> Unit) { // Spoiler: Unit type
val summed = a + b
callback(summed)
}
Higher-Order Functions & Lambda
Sample.kt
124. fun sum(a: Int, b: Int, callback: (Int) -> Unit) {
val summed = a + b
callback(summed)
}
Higher-Order Functions & Lambda
Sample.kt
125. fun sum(a: Int, b: Int, callback: (Int) -> Unit) {
val summed = a + b
callback(summed)
}
sum(1, 2) { result ->
println(result) // prints 3
}
Higher-Order Functions & Lambda
Sample.kt
126. fun sum(a: Int, b: Int, callback: (Int) -> Unit) {
val summed = a + b
callback(summed)
}
sum(1, 2) {
println(it) // Also prints 3
}
Higher-Order Functions & Lambda
Sample.kt
127. val sum: (Int, Int) -> Int = { x: Int, y: Int ->
x + y
}
Higher-Order Functions & Lambda
Sample.kt
128. val sum: (Int, Int) -> Int = { x: Int, y: Int -> x + y }
Higher-Order Functions & Lambda
Sample.kt
129. val sum = { x: Int, y: Int -> x + y }
Higher-Order Functions & Lambda
Sample.kt
130. val sum = { x: Int, y: Int -> x + y }
val sub = { x: Int, y: Int -> x - y }
Higher-Order Functions & Lambda
Sample.kt
131. val sum = { x: Int, y: Int -> x + y }
val sub = { x: Int, y: Int -> x - y }
fun calculation(a: Int, b: Int, rule: (Int, Int) -> Int): Int {
return rule(a, b)
}
Higher-Order Functions & Lambda
Sample.kt
132. val sum = { x: Int, y: Int -> x + y }
val sub = { x: Int, y: Int -> x - y }
fun calculation(a: Int, b: Int, rule: (Int, Int) -> Int): Int {
return rule(a, b)
}
Higher-Order Functions & Lambda
Sample.kt
133. val sum = { x: Int, y: Int -> x + y }
val sub = { x: Int, y: Int -> x - y }
fun calculation(a: Int, b: Int, rule: (Int, Int) -> Int): Int {
return rule(a, b)
}
Higher-Order Functions & Lambda
Sample.kt
134. val sum = { x: Int, y: Int -> x + y }
val sub = { x: Int, y: Int -> x - y }
fun calculation(a: Int, b: Int, rule: (Int, Int) -> Int): Int {
return rule(a, b)
}
calculation(3, 2, sum)
Higher-Order Functions & Lambda
Sample.kt
135. val sum = { x: Int, y: Int -> x + y }
val sub = { x: Int, y: Int -> x - y }
fun calculation(a: Int, b: Int, rule: (Int, Int) -> Int): Int {
return rule(a, b)
}
calculation(3, 2, sum) // returns 5
Higher-Order Functions & Lambda
Sample.kt
136. val sum = { x: Int, y: Int -> x + y }
val sub = { x: Int, y: Int -> x - y }
fun calculation(a: Int, b: Int, rule: (Int, Int) -> Int): Int {
return rule(a, b)
}
calculation(3, 2, sum)
calculation(3, 2, sub)
Higher-Order Functions & Lambda
Sample.kt
137. val sum = { x: Int, y: Int -> x + y }
val sub = { x: Int, y: Int -> x - y }
fun calculation(a: Int, b: Int, rule: (Int, Int) -> Int): Int {
return rule(a, b)
}
calculation(3, 2, sum)
calculation(3, 2, sub) // returns 1
Higher-Order Functions & Lambda
Sample.kt
138. val sum = { x: Int, y: Int -> x + y }
val sub = { x: Int, y: Int -> x - y }
fun calculation(a: Int, b: Int, rule: (Int, Int) -> Int): Int {
return rule(a, b)
}
calculation(3, 2, sum)
calculation(3, 2, sub)
Higher-Order Functions & Lambda
Sample.kt
139. val sum = { x: Int, y: Int -> x + y }
val sub = { x: Int, y: Int -> x - y }
fun calculation(a: Int, b: Int, rule: (Int, Int) -> Int): Int {
return rule(a, b)
}
calculation(3, 2, { x, y ->
x * y
})
Higher-Order Functions & Lambda
Sample.kt
140. val sum = { x: Int, y: Int -> x + y }
val sub = { x: Int, y: Int -> x - y }
fun calculation(a: Int, b: Int, rule: (Int, Int) -> Int): Int {
return rule(a, b)
}
calculation(3, 2, { x, y ->
x * y
}) // returns 6
Higher-Order Functions & Lambda
Sample.kt
141. val sum = { x: Int, y: Int -> x + y }
val sub = { x: Int, y: Int -> x - y }
fun calculation(a: Int, b: Int, rule: (Int, Int) -> Int): Int {
return rule(a, b)
}
calculation(3, 2) { x, y ->
x * y
}
Higher-Order Functions & Lambda
Sample.kt
142. val sum = { x: Int, y: Int -> x + y }
val sub = { x: Int, y: Int -> x - y }
fun calculation(a: Int, b: Int, rule: (Int, Int) -> Int): Int {
return rule(a, b)
}
calculation(3, 2) { x, y -> x * y }
Higher-Order Functions & Lambda
Sample.kt
143. val sum = { x: Int, y: Int -> x + y }
val sub = { x: Int, y: Int -> x - y }
fun calculation(a: Int, b: Int, rule: (Int, Int) -> Int): Int {
return rule(a, b)
}
fun sum(a: Int, b: Int) = a + b
calculation(3, 2, ::sum)
Higher-Order Functions & Lambda
Sample.kt
157. class Coffee(type: String)
class Coffee(var type: String)
class Coffee(val type: String)
class Coffee(private val type: String)
Constructor
Coffee.kt
158. class Coffee(type: String)
class Coffee(var type: String)
class Coffee(val type: String)
class Coffee(private val type: String)
class Coffee(private val type: String = "Espresso")
Constructor
Coffee.kt
170. class Coffee {
val type: String by lazy {
println("You are running this code!")
"Hello"
}
val x = type
val y = type
}
Properties
Coffee.kt
171. class Coffee {
val type: String by lazy {
println("You are running this code!")
"Hello"
}
val x = type // It prints "You are running this code!" 1 time
val y = type // It don't prints anything
}
Properties
Coffee.kt
179. open class Coffee {
open fun drink() {
println("So tasty")
}
}
class Cappuccino : Coffee() {
override fun drink() {
super.drink()
}
}
Inheritance
Coffee.kt
182. interface Drinkable {
fun drink()
}
class Coffee : Drinkable {
override fun drink() {
println("So tasty")
}
}
Interfaces
Coffee.kt
183. interface Drinkable {
fun drink() {
println("So tasty")
}
}
class Coffee : Drinkable
Interfaces
Coffee.kt
184. interface Drinkable {
val type: String
}
class Coffee : Drinkable {
override val type = "Coffee"
}
Interfaces
Coffee.kt
185. open class Coffee
interface Drinkable {
fun drink()
}
class Cappuccino : Coffee(), Drinkable {
override fun drink() {
println("So tasty")
}
}
Interfaces
Coffee.kt
186. open class Coffee {
open fun drink() = println("So coffee")
}
interface Drinkable {
fun drink() = println("So tasty")
}
class Cappuccino : Coffee(), Drinkable {
// What happens here ?
}
Interfaces
Coffee.kt
187. open class Coffee {
open fun drink() = println("So coffee")
}
interface Drinkable {
fun drink() = println("So tasty")
}
class Cappuccino : Coffee(), Drinkable {
override fun drink() {
super<Coffee>.drink()
super<Drinkable>.drink()
}
}
Interfaces
Coffee.kt
190. data class Coffee(val type: String)
val a = Coffee("Cappuccino")
val b = Coffee("Cappuccino")
println(a == b) // Prints true
Data Classes - Equals & HashCode
Coffee.kt
191. data class Coffee(val type: String)
val a = Coffee("Cappuccino")
val b = Coffee("Ristretto")
println(a == b) // Prints false
Data Classes - Equals & HashCode
Coffee.kt
192. data class Coffee(val type: String)
val a = Coffee("Cappuccino")
println(a.toString()) // Prints: Coffee(type=Cappuccino)
Data Classes - toString()
Coffee.kt
193. data class Coffee(val type: String)
val a = Coffee("Cappuccino")
val b = a.copy()
Data Classes - copy
Coffee.kt
194. data class Coffee(val type: String)
val a = Coffee("Cappuccino")
val b = a.copy()
val c = a.copy(type = "Ristretto")
Data Classes - copy
Coffee.kt
222. listOf("Hello", "World")
.forEachIndexed { index, item ->
println("Item $item at index $index")
}
// Prints: Item Hello at index 0 and Item World at index 1
Collections - Operators - Filter
Sample.kt
223. listOf(1, 2, 3, 4, 5)
.map { it * 2 }
.forEach { println(it) }
// Prints 2, 4, 6, 8 and 10
Collections - Operators - Map
Sample.kt
224. listOf(5, 3, 1, 4, 2)
.sortedBy { it }
.forEach { println(it) }
// Prints 1, 2, 3, 4 and 5
Collections - Operators - Sort
Sample.kt