Tutorial by Examples

Go to File -> Settings -> Editor -> Colors & Fonts -> Android Logcat Change the colors as you need: Choose the appropriate color:
Some basic types and classes in Java are fundamentally mutable. For example, all array types are mutable, and so are classes like java.util.Data. This can be awkward in situations where an immutable type is mandated. One way to deal with this is to create an immutable wrapper for the mutable type...
enable_shared_from_this enables you to get a valid shared_ptr instance to this. By deriving your class from the class template enable_shared_from_this, you inherit a method shared_from_this that returns a shared_ptr instance to this. Note that the object must be created as a shared_ptr in first pl...
This example shows how to create a delegate that encapsulates the method that returns the current time static DateTime UTCNow() { return DateTime.UtcNow; } static DateTime LocalNow() { return DateTime.Now; } static void Main(string[] args) { Func<DateTime> method = U...
static int Sum(int a, int b) { return a + b; } static int Multiplication(int a, int b) { return a * b; } static void Main(string[] args) { Func<int, int, int> method = Sum; // method points to the Sum method // that retuns 1 int variable and takes 2 int vari...
An anonymous method can be assigned wherever a delegate is expected: Func<int, int> square = delegate (int x) { return x * x; } Lambda expressions can be used to express the same thing: Func<int, int> square = x => x * x; In either case, we can now invoke the method stored ins...
Func also supports Covariant & Contravariant // Simple hierarchy of classes. public class Person { } public class Employee : Person { } class Program { static Employee FindByTitle(String title) { // This is a stub for a method that returns // an employee that h...
This example demonstrates how to fetch the URI's of system ringtones (RingtoneManager.TYPE_RINGTONE): private List<Uri> loadLocalRingtonesUris() { List<Uri> alarms = new ArrayList<>(); try { RingtoneManager ringtoneMgr = new RingtoneManager(getActivi...
This example shows how to use a request interceptor with OkHttp. This has numerous use cases such as: Adding universal header to the request. E.g. authenticating a request Debugging networked applications Retrieving raw response Logging network transaction etc. Set custom user agent Retrof...
For any object (i.e, variable, array, union, struct, pointer or function) the unary address operator can be used to access the address of that object. Suppose that int i = 1; int *p = NULL; So then a statement p = &i;, copies the address of the variable i to the pointer p. I...
Please see here: Pointer Arithmetic
An immutable object is an object whose state cannot be changed. An immutable class is a class whose instances are immutable by design, and implementation. The Java class which is most commonly presented as an example of immutability is java.lang.String. The following is a stereotypical example: ...
The double-colon syntax of names in the use statement looks similar to names used elsewhere in the code, but meaning of these paths is different. Names in the use statement by default are interpreted as absolute, starting at the crate root. Names elsewhere in the code are relative to the current mo...
Assuming you have this YAML locale file: # config/locales/en.yml en: header: title: "My header title" and you want to display your title string, you can do this # in ERB files <%= t('header.title') %> # in SLIM files = t('header.title')
You can pass parameters to I18n t method: # Example config/locales/en.yml en: page: users: "%{users_count} users currently online" # In models, controller, etc... I18n.t('page.users', users_count: 12) # In views # ERB <%= t('page.users', users_count: 12) %> #S...
You can let I18n handle pluralization for you, just use count argument. You need to set up your locale file like this: # config/locales/en.yml en: online_users: one: "1 user is online" other: "%{count} users are online" And then use the key you just created by ...
In most cases, you may want to set I18n locale. One might want to set the locale for the current session, the current user, or based on a URL parameter This is easily achievable by implementing a before_action in one of your controllers, or in ApplicationController to have it in all of your controll...
Anonymous methods provide a technique to pass a code block as a delegate parameter. They are methods with a body, but no name. delegate int IntOp(int lhs, int rhs); class Program { static void Main(string[] args) { // C# 2.0 definition IntOp add = delegate(int lhs,...
Array.join(separator) can be used to output an array as a string, with a configurable separator. Default (separator = ","): ["a", "b", "c"].join() === "a,b,c" With a string separator: [1, 2, 3, 4].join(" + ") === "1 + 2 + 3 + 4&q...
<?xml version="1.0" encoding="utf-8" ?> <Employees> <Employee> <EmpId>1</EmpId> <Name>Sam</Name> <Sex>Male</Sex> <Phone Type="Home">423-555-0124</Phone> <Phone Type="Work&quot...

Page 355 of 1336