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
//services.js | |
angular.module('tutorialApp.services', []) | |
.factory('MyService', ['MyOtherService', function(MyOtherService) { | |
return { | |
doWork: function() { | |
return MyOtherService.doWork(); | |
} | |
} | |
}]) | |
.factory('MyOtherService', [function() { |
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
//controller.js | |
describe('tutorialApp controllers', function() { | |
beforeEach(module('tutorialApp.controllers')); | |
describe('TutorialCtrl', function(){ | |
var scope, ctrl; | |
beforeEach(inject(function(_$httpBackend_, $rootScope, $controller) { | |
scope = $rootScope.$new(); |
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 myString: String = null //Error: Null can not be a value of a non-null type String |
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 myString: String? = null |
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 myString: String? = null | |
println(myString.length) //Error: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type String? |
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 myString: String? = null | |
val length = myString?.length | |
println("Length of myString: $length") |
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
if (person != null && person.getPersonId() != null && person.getPersonId().getId() != null && person.getPersonId().getId().getIntValue() != null) { | |
… | |
} else { | |
return null; | |
} |
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
return person.?getPersonId().?getId().?getIntvalue() |
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
String myString = null; | |
int length = myString != null ? myString.length() : 0; | |
System.out.println("Length of myString: " + length); |
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
var myString: String? = null | |
val length = myString?.length ?: 0 | |
println("Length of myString: $length") |
OlderNewer