mirror of
https://github.com/sharkdp/bat.git
synced 2025-08-18 03:59:42 +01:00
.github
assets
diagnostics
doc
examples
src
tests
benchmarks
examples
mocked-pagers
scripts
snapshots
syntax-tests
highlighted
source
ARM Assembly
ASP
AWK
ActionScript
Ada
Apache
AppleScript
AsciiDoc
Assembly (x86_64)
Bash
BatTestCustomAssets
Batch
BibTeX
C
C-Sharp
CMake
CSS
CSV
Cabal
Clojure
CoffeeScript
Cpp
CpuInfo
Crontab
Crystal
D
Dart
Diff
Dockerfile
DotENV
Elixir
Elm
Email
Erlang
EtcGroup
F#
Fish
Fortran (Fixed Form)
Fortran (Modern)
Fortran Namelist
Fstab
GLSL
Git Attributes
Git Config
Git Ignore
Go
GraphQL
Graphviz DOT
Groff
Groovy
HTML
Haskell
Hosts
INI
Ignored suffixes
JQ
JSON
Java
Java Server Page (JSP)
JavaScript
Jinja2
Julia
Kotlin
test.kt
LLVM
Lean
Less
Lisp
Literate Haskell
LiveScript
Log
Lua
MATLAB
Makefile
Manpage
Markdown
MediaWiki
MemInfo
NAnt Build File
NSE
NSIS
Ninja
OCaml
Objective-C
Objective-C++
PHP
Pascal
Passwd
Perl
Plaintext
PowerShell
Protocol Buffer
Puppet
PureScript
Python
QML
R
Racket
Rego
Regular Expression
Requirements.txt
Robot Framework
Ruby
Ruby Haml
Ruby On Rails
Rust
SCSS
SLS
SML
SQL
SSH Config
SSHD Config
Sass
Scala
Slim
Solidity
Strace
Stylus
Svelte
Swift
Syslog
SystemVerilog
TOML
Tcl
TeX
Terraform
Textile
Todo.txt
TypeScript
TypeScriptReact
Verilog
VimHelp
VimL
Vue
Vyper
XAML
XML
YAML
Zig
cmd-help
dash
fish_history
gnuplot
http-request-response
jsonnet
nginx
nim
nix
orgmode
reStructuredText
resolv.conf
varlink
BatTestCustomAssets.sublime-syntax
compare_highlighted_versions.py
create_highlighted_versions.py
regression_test.sh
test_custom_assets.sh
update.sh
tester
utils
.gitattributes
assets.rs
integration_tests.rs
no_duplicate_extensions.rs
snapshot_tests.rs
system_wide_config.rs
test_pretty_printer.rs
.gitignore
.gitmodules
CHANGELOG.md
CONTRIBUTING.md
Cargo.lock
Cargo.toml
LICENSE-APACHE
LICENSE-MIT
NOTICE
README.md
build.rs
rustfmt.toml
86 lines
1.9 KiB
Kotlin
Vendored
86 lines
1.9 KiB
Kotlin
Vendored
import kotlin.math.*
|
|
|
|
data class Example(
|
|
val name: String,
|
|
val numbers: List<Int?>
|
|
)
|
|
|
|
fun interface JokeInterface {
|
|
fun isFunny(): Boolean
|
|
}
|
|
|
|
abstract class AbstractJoke : JokeInterface {
|
|
override fun isFunny() = false
|
|
abstract fun content(): String
|
|
}
|
|
|
|
class Joke : AbstractJoke() {
|
|
override fun isFunny(): Boolean {
|
|
return true
|
|
}
|
|
override fun content(): String = "content of joke here, haha"
|
|
}
|
|
|
|
class DelegatedJoke(val joke: Joke) : JokeInterface by joke {
|
|
val number: Long = 123L
|
|
|
|
companion object {
|
|
const val someConstant = "some constant text"
|
|
}
|
|
}
|
|
|
|
object SomeSingleton
|
|
|
|
sealed class Shape {
|
|
abstract fun area(): Double
|
|
}
|
|
|
|
data class Square(val sideLength: Double) : Shape() {
|
|
override fun area(): Double = sideLength.pow(2)
|
|
}
|
|
|
|
object Point : Shape() {
|
|
override fun area() = .0
|
|
}
|
|
|
|
class Circle(val radius: Double) : Shape() {
|
|
override fun area(): Double {
|
|
return PI * radius * radius
|
|
}
|
|
}
|
|
|
|
fun String.extensionMethod() = "test"
|
|
|
|
fun main() {
|
|
val name = """
|
|
multiline
|
|
string
|
|
|
|
some numbers: 123123 42
|
|
""".trimIndent()
|
|
val example = Example(name = name, numbers = listOf(512, 42, null, -1))
|
|
|
|
example.numbers
|
|
.filterNotNull()
|
|
.forEach { println(it) }
|
|
|
|
setOf(Joke(), DelegatedJoke(Joke()).joke)
|
|
.filter(JokeInterface::isFunny)
|
|
.map(AbstractJoke::content)
|
|
.forEachIndexed { index: Int, joke ->
|
|
println("I heard a funny joke(#${index + 1}): $joke")
|
|
}
|
|
|
|
listOf(Square(12.3), Point, Circle(5.2))
|
|
.associateWith(Shape::area)
|
|
.toList()
|
|
.sortedBy { it.second }
|
|
.forEach {
|
|
println("${it.first}: ${it.second}")
|
|
}
|
|
|
|
println("some string".extensionMethod())
|
|
|
|
require(SomeSingleton::class.simpleName == "SomeSingletonName") { "something does not seem right..." }
|
|
}
|