Monthly Archives: April 2008

Strings (Part 2)

The types of substitution can be easily seen such as; strings inside a single quote have two consecutive backslashes interpreted as one, a backslash followed by a single quote is interpreted as a single quote and so on and so forth as shown below.
‘escape using “\\”‘ >> escape using “\”
‘That\’s right’ >> That’s right
Stings that are double-quoted have the [...]

Posted in Development, Programming Basics | Tagged , | Comments closed

Strings (Part 1)

Strings are objects of class String, which are normally simple 8-bit bytes that normally hold printable characters but that is not a requirement as you would see for they could also be used to hold binary data. Created using string literals (which are sequences of characters between delimiters that themselves do some conversion of the [...]

Posted in Development, Programming Basics | Tagged , , | Comments closed

Perl Differences in string handling

A note to Perl users, strings that contain numbers will not be automatically converted to numbers when used in an expression such as when trying to read numbers from a file like the one below does.
DATA.each do |line|
vals = line.split # split line, storing tokens in val
[...]

Posted in Development, Programming Basics | Tagged , | Comments closed

Blocks as Closures (Part 3)

That’s where blocks come in, to simplify the definition and use of these buttons making maintenance simpler so we could call the specific block to which we pass on the necessary parameters or methods to attain the final outcome. Below is an example of how this can be achieved with blocks creating a class called [...]

Posted in Development, Programming Basics | Tagged , | Comments closed

Blocks as Closures (Part 2)

Sample Code:
class PlayButton < Button
def initialize
super(“Play”) # invoke Button’s initialize process
end
def buttonSelected
# do something that should be done when the start button is pressed
end
end
bPlay = PlayButton.new
This type of approach would bring about two [...]

Posted in Development, Programming Basics | Tagged , | Comments closed

Blocks as Closures (Part 1)

As it turns out, blocks are the ideal tool for use ion implementing user interfaces where we have a defined graphic that signifies a button and pressing that button would result in a pre-set series of processes. A simple button definition can be:
bPlay = Button.new(“Play”)
bPause = Button.new(“Pause”)
# so on and so forth……
If a user presses [...]

Posted in Development, Programming Basics | Tagged , | Comments closed