Tutorial by Examples

There are two different types of descriptors. Data descriptors are defined as objects that define both a __get__() and a __set__() method, whereas non-data descriptors only define a __get__() method. This distinction is important when considering overrides and the namespace of an instance's dictiona...
The widely used combination of tic and toc can provide a rough idea of the execution time of a function or code snippets. For comparing several functions it shouldn't be used. Why? It is almost impossible to provide equal conditions for all code snippets to compare within a script using above solu...
The OverloadedStrings language extension allows the use of normal string literals to stand for Text values. {-# LANGUAGE OverloadedStrings #-} import qualified Data.Text as T myText :: T.Text myText = "overloaded"
{-# LANGUAGE OverloadedStrings #-} import qualified Data.Text as T myText :: T.Text myText = "\n\r\t leading and trailing whitespace \t\r\n" strip removes whitespace from the start and end of a Text value. ghci> T.strip myText "leading and trailing whitespace" ...
{-# LANGUAGE OverloadedStrings #-} import qualified Data.Text as T myText :: T.Text myText = "mississippi" splitOn breaks a Text up into a list of Texts on occurrences of a substring. ghci> T.splitOn "ss" myText ["mi","i","ippi"] sp...
Encoding and decoding functions for a variety of Unicode encodings can be found in the Data.Text.Encoding module. ghci> import Data.Text.Encoding ghci> decodeUtf8 (encodeUtf8 "my text") "my text" Note that decodeUtf8 will throw an exception on invalid input. If you wa...
Type ghci at a shell prompt to start GHCI. $ ghci GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help Prelude>
By default, GHCI's prompt shows all the modules you have loaded into your interactive session. If you have many modules loaded this can get long: Prelude Data.List Control.Monad> -- etc The :set prompt command changes the prompt for this interactive session. Prelude Data.List Control.Monad&g...
GHCi uses a configuration file in ~/.ghci. A configuration file consists of a sequence of commands which GHCi will execute on startup. $ echo ":set prompt \"foo> \"" > ~/.ghci $ ghci GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration...
The :l or :load command type-checks and loads a file. $ echo "f = putStrLn \"example\"" > example.hs $ ghci GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help ghci> :l example.hs [1 of 1] Compiling Main ( example.hs, interpreted ) Ok, modules ...
(u)gettext_noop allows you to mark a string as translatable without actually translating it. A typical use case is when you want to log a message for developers (in English) but also want to display it to the client (in the requested language). You can pass a variable to gettext, but its content wo...
Arrays can be used as plain constants and class constants from version PHP 5.6 onwards: Class constant example class Answer { const C = [2,4]; } print Answer::C[1] . Answer::C[0]; // 42 Plain constant example const ANSWER = [2,4]; print ANSWER[1] . ANSWER[0]; // 42 Also from versi...
Find usages / Find usages in file Windows / Linux: Alt + F7 / Ctrl + F7 OS X / macOS: Option + F7 / Ctrl + F7 Highlight usages in file Windows / Linux: Ctrl + Shift + F7 OS X / macOS: Cmd + Shift + F7 Show usages Windows / Linux: Ctrl + Alt + F7 OS X / macOS: Cmd + Option + F7
Windows / Linux: Ctrl + P OS X / macOS: Cmd + P Shows what parameters a method and all of its overloads accepts.
The fourth version of the framework focuses mainly on making mobile web application development easier. New features in AP.NET MVC 4 ASP.NET Web API ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devi...
Lets suppose you have 2 Lists A and B, and you want to remove from B all the elements that you have in A the method in this case is List.removeAll(Collection c); #Example: public static void main(String[] args) { List<Integer> numbersA = new ArrayList<>(); List<Intege...
Regular Map A map is an associative container, containing key-value pairs. #include <string> #include <map> std::map<std::string, size_t> fruits_count; In the above example, std::string is the key type, and size_t is a value. The key acts as an index in the map. Each key mu...
Reverse elements within a tuple colors = "red", "green", "blue" rev = colors[::-1] # rev: ("blue", "green", "red") colors = rev # colors: ("blue", "green", "red") Or using reversed (reversed gives an it...
def str = 'Single quoted string' assert str instanceof String
def str = "Double quoted string" assert str instanceof String

Page 451 of 1336