This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name New Userscript | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://test.vntu.edu.ua/web_thesaurus/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=hibbard.eu | |
// @grant none | |
// ==/UserScript== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val child = parentObj.child?.child?.child | |
if (child != null) { | |
doSomethingOnBooleanValue(child.isValid) | |
} else { | |
// handle null value here | |
} | |
fun doSomethingOnBooleanValue(valid: Boolean) { | |
if (valid) { | |
// `valid` is really true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class Parent(val child: Nested?) | |
class Nested(val child: Nested?, val isValid: Boolean = false) | |
// Assume you got this object from the dark and deep internals of your app | |
val parentObj = getParentObjFromInternals() | |
doSomethingOnBooleanValue(parentObj.child?.child?.child?.isValid) | |
fun doSomethingOnBooleanValue(valid: Boolean?) { | |
if (valid == true) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Arrange | |
data class Parent(val child: Nested?) | |
class Nested(val child: Nested?, val isValid : Boolean = false) | |
// Assume you got this object from the dark and deep internals of your app | |
val parentObj = getParentObjFromInternals() | |
// This is straightforward but it won't work | |
if (parentObj.child?.child?.child?.isValid) { | |
// Error. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun childFunction(parentObj: Parent) { | |
// Do whatever needed with child obj | |
println("child = ${parentObj.child.child?.child?.child}") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun parentFunction() { | |
val parentObj = Parent(Child()) | |
childFunction(parentObj) | |
} | |
fun childFunction(parentObj: Parent) { | |
// Do whatever needed with child obj | |
println("child = ${parentObj.child}") | |
} | |
data class Parent(val child: Child) | |
class Child |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | |
<!DOCTYPE report | |
PUBLIC '-//JACOCO//DTD Report 1.1//EN' | |
'report.dtd'> | |
<report name="app"> | |
<sessioninfo dump="1575989429103" id="fv-az606-3e43c913" start="1575989418154"/> | |
<package name=" com/java/android/example/domain/model"> | |
<class name=" com/java/android/example/domain/model/TripEvents" sourcefilename="Trip.kt"> | |
<method desc="()Ljava/lang/String;" line="40" name="getDistance"> | |
<counter covered="0" missed="3" type="INSTRUCTION"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TokenDataProviderTest { | |
@Test | |
fun `cast issue`() { | |
val result = TokenDataProvider() | |
.getToken() | |
.blockingFirst() | |
result.fold({ | |
assertEquals(it, "token") | |
}, { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TokenDataProvider { | |
fun getToken(): Observable<Result<String>> { | |
// Just return sample string | |
return Observable.just("token") | |
.toResult() | |
} | |
} | |
/** | |
* Just an handful extension function which wraps any value or error produced by [Observable] into [Result]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ -z "${CI_PULL_REQUEST}" ]]; then | |
echo "---> Making build outside of Pull Request (building single commit or branch)" | |
./gradlew gnagCheck | |
else | |
echo "---> Making build for Pull Request" | |
# In the env variable CI_PULL_REQUEST CircleCI provides the URL of the PR (like https://github.com/amatkivskiy/sample/pull/3) | |
# But for the Gnag task we need PR number (simply 3) | |
# ${CI_PULL_REQUEST##*/} means that we simply get '3' from the URL provided in CI_PULL_REQUEST/ |
NewerOlder