Ruby → User Guide #15 - Ruby - access control
access control, Ruby, ruby lesson, ruby уроки, user guide, контроль доступа, руководство пользователя
Earlier, we said that ruby has no functions, only methods. However there is more than one kind of method. In this chapter we introduce access controls .
Consider what happens when we define a method in the "top level", not …
ReadRuby → User Guide #14 - Ruby - Redefinition of methods
Ruby, ruby lesson, ruby уроки, user guide, переопределение методов, руководство пользователя
In a subclass, we can change the behavior of the instances by redefining superclass methods.
Readruby> class Human | def identify | print "I'm a person.\n" | end | def train_toll(age) | if age < 12 | print "Reduced fare.\n"; …
Ruby → User Guide #13 - Ruby - Inheritance
Inheritance, Ruby, ruby lesson, ruby уроки, user guide, наследование, руководство пользователя
Our classification of objects in everyday life is naturally hierarchical. We know that all cats are mammals , and all mammals are animals . Smaller classes inherit characteristics from the larger classes to which they belong. If all mammals breathe, …
ReadRuby → User Guide #12 - Ruby - classes
class, Ruby, ruby lesson, ruby уроки, user guide, класс, руководство пользователя
The real world is filled by objects, and we can classify them. For example, a very small child is likely to say "bow-wow" when seeing a dog, regardless of the breed; we naturally see the world in terms of these …
ReadRuby → User Guide #11 - Ruby - methods
methods, Ruby, ruby lesson, ruby уроки, user guide, методы, руководство пользователя
What is a method? In OO programming, we don't think of operating on data directly from outside an object; rather, objects have some understanding of how to operate on themselves (when asked nicely to do so). You might say we …
ReadRuby → User Guide #10 - Ruby - Object-oriented thinking
Ruby, ruby lesson, ruby уроки, user guide, ооп, руководство пользователя
Object oriented is a catchy phrase. To call anything object oriented can make you sound pretty smart. Ruby claims to be an object oriented scripting language; but what exactly does "object oriented" mean?
There have been a variety of answers …
ReadRuby → User Guide #09 - Ruby - iterators
interators, Ruby, ruby lesson, ruby уроки, user guide, итераторы, руководство пользователя
Iterators are not an original concept with ruby. They are in common use in object-oriented languages. They are also used in Lisp, though there they are not called iterators. However the concepet of iterator is an unfamiliar one for many …
ReadRuby → User Guide #08 - Ruby - control structures
case, for, Ruby, ruby lesson, ruby уроки, user guide, while, руководство пользователя
This chapter explores more of ruby's control structures.
case
We use the case statement to test a sequence of conditions. This is superficially similar to switch in C and Java but is considerably more powerful, as we shall see.
Readruby> …
Ruby → User Guide #07 - Ruby - Back to the simple examples
руководство пользователя, ruby lesson, Ruby, ruby уроки, user guide, regular expressions, string
Now let's take apart the code of some of our previous example programs.
The following appeared in the simple examples chapter.
def fact(n) if n == 0 1 else n * fact(n-1) end end print fact(ARGV[0].to_i), "\n"
Because this is …
ReadRuby → User Guide #06 - Ruby - arrays
arrays, Ruby, ruby lesson, ruby уроки, user guide, массивы, руководство пользователя
You can create an array by listing some items within square brackets ([]) and separating them with commas. Ruby's arrays can accomodate diverse object types.
ruby> ary = [1, 2, "3"] [1, 2, "3"]
Arrays can be concatenated or repeated …
ReadRuby → User Guide #05 - Ruby - Regular expressions
user guide, регулярные выражения, ruby lesson, Ruby, ruby уроки, руководство пользователя, regular expressions
Let's put together a more interesting program. This time we test whether a string fits a description, encoded into a concise pattern .
There are some characters and character combinations that have special meaning in these patterns, including:
[] - …
ReadRuby → User Guide #04 - Ruby - Strings
Ruby, ruby lesson, ruby уроки, user guide, руководство пользователя
Ruby deals with strings as well as numerical data. A string may be double-quoted ("...") or single-quoted ('...').
ruby> "abc" "abc" ruby> 'abc' "abc"
Double- and single-quoting have different effects in some cases. A double-quoted string allows character escapes by …
Read- Akiv Doros
- Nov. 12, 2024, 1:58 a.m.
C ++ - Test 004. Pointers, Arrays and Loops
- Result:50points,
- Rating points-4
- molni99
- Oct. 26, 2024, 11:37 a.m.
C ++ - Test 004. Pointers, Arrays and Loops
- Result:80points,
- Rating points4
- molni99
- Oct. 26, 2024, 11:29 a.m.
C ++ - Test 004. Pointers, Arrays and Loops
- Result:20points,
- Rating points-10