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 Main { | |
public Optional<String> someValue = Optional.absent(); | |
public static void main(String... arguments){ | |
Main m = new Main(); | |
String foo = m.someValue.or("default value"); | |
System.out.println(foo); //outputs "defaultValue" |
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 Main { | |
public Optional<String> someValue = Optional.absent(); | |
public Optional<String> someOtherValue = Optional.of("test"); | |
public static void main(String... arguments){ | |
Main m = new Main(); | |
if(m.someValue.isPresent()){ |
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
<?php | |
$foo = array("ala", "ma", "kota"); | |
foreach($foo as $text){ | |
echo $text; | |
} | |
?> |
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
<?php | |
$foo = array( | |
"bar" => 10, | |
"baz" => "zzz" | |
); | |
$foo54 = ["bar" => 10, "baz" => "zzz"]; //valid from php 5.4 | |
?> |
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 TestSubject3refactored(doFoo1: DoFoo1, doFoo2: DoFoo2) { | |
val prop1 = 1; | |
val prop2 = 2; | |
def doFoo():Boolean = { | |
val someText = doFoo1.doFoo1(prop1) | |
val textToSend = doFoo2.doFoo2(someText, prop2) | |
return callSomeWebService(textToSend) |
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 TestSubject3 { | |
val prop1 = 1; | |
val prop2 = 2; | |
def doFoo():Boolean = { | |
val someText = doFoo1(); | |
val textToSend = doFoo2(someText); | |
return callSomeWebService(textToSend); |
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 BazRefactored(bar: Bar) { | |
def doRealyFoo(input: Int):Int = { | |
return bar.i + input | |
} | |
} | |
class BazRefactoredMock extends BazRefactored(new Bar(10)) { | |
} |
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 Bar(var i: Int) { | |
} | |
class Baz(bar: Bar) { | |
var barProperty = bar | |
} | |
class TestSubject2 { |
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 TestCase1refactored { | |
def doFoo(bar: Bar): Bar = { | |
val result = new Bar(bar.i + 10) | |
return result | |
} | |
} | |
def testCase1refactored() { |
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 Bar(var i: Int) { | |
} | |
class TestSubject1 { | |
def doFoo(bar: Bar){ | |
bar.i = 10 | |
} | |