This file contains hidden or 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 main() { | |
val valueIs = "Jack and jill went up the hill!" | |
val result = valueIs.also { | |
it.contains("jill") | |
} | |
println(valueIs) // o/p - Jack and jill went up the hill! | |
println(result) // o/p - Jack and jill went up the hill! | |
} |
This file contains hidden or 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 main() { | |
val valueIs = "Jack and jill went up the hill!" | |
val result = with(valueIs) { | |
this.contains("yup") | |
} | |
println(valueIs) // o/p - Jack and jill went up the hill! | |
println(result) // o/p - false | |
} |
This file contains hidden or 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 main() { | |
val val1 = run { | |
"function" | |
// true | |
} | |
val val2 = run { | |
// "function" | |
true | |
} | |
println(val1) // function |
This file contains hidden or 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 main() { | |
val valueIs = "Jack and jill went up the hill!" | |
val result = valueIs.run { | |
this.contains("help") | |
} | |
println(valueIs) // o/p - Jack and jill went up the hill! | |
println(result) // o/p - false | |
} |
This file contains hidden or 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 main() { | |
val valueIs = "Jack and jill went up the hill!" | |
val result = valueIs.let { | |
it.contains("help") | |
} | |
println(valueIs) // o/p - Jack and jill went up the hill! | |
println(result) // o/p - false | |
} |
This file contains hidden or 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
@Bind(R.id.baseLayout) | |
RelativeLayout baseLayout; | |
@Bind(R.id.button) | |
Button delegate; | |
private void init() { | |
baseLayout.post(new Runnable() { | |
@Override | |
public void run() { |
This file contains hidden or 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 MainActivity : AppCompatActivity() { | |
@Inject lateinit var info: Info | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
DaggerMagicBox.create().poke(this) | |
text_view.text = info.text | |
} |
This file contains hidden or 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 AppRepositoryInjectTest { | |
@Inject | |
lateinit var appAPIs: AppAPIs | |
@Before | |
fun setUp() { | |
val component = DaggerTestAppComponent.builder() | |
.applicationModule(TestApplicationModule(GDelegate())) | |
.build() |
This file contains hidden or 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
@Singleton | |
@Component( | |
modules = [ | |
(ApplicationModule::class) | |
] | |
) | |
interface TestAppComponent : ApplicationComponent { | |
fun into(appRepositoryTest: AppRepositoryInjectNamedTest) | |
fun into(appRepositoryTest: AppRepositoryInjectTest) | |
fun into(baseTest: BaseTest) |
This file contains hidden or 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 TestApplicationModule(delegate: GDelegate) : ApplicationModule(delegate) { | |
override fun giveAppAPIs(): AppAPIs = mockk() | |
override fun giveRetrofitService(okHttpClient: OkHttpClient): AppAPIs = mockk() | |
override fun giveOkHttpClient(loggingInterceptor: HttpLoggingInterceptor): OkHttpClient = mockk() | |
override fun giveLoggingInterceptor(): HttpLoggingInterceptor = mockk() | |
} |