- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
class StaticArray { // TO DO: add float, char, double
private $min = 0;
private $lengch = 0;
private $max = 0;
private $array = array();
function __construct($lengch,$type) {
if (!is_numeric($lengch) || $type != 'int'&& $type != 'long'&& $type != 'byte'&& $type != 'short'){
echo "BAD ARRRAY TYPE OR LENGCH!\n";
return false;
}
$this->lengch = $lengch;
switch ($type){
case 'int':
$this->min = -2147483647;
$this->max = 2147483648;
break;
case 'byte':
$this->min = -127;
$this->max = 128;
break;
case 'short':
$this->min = -32768;
$this->max = 32767;
break;
case 'long':
$this->min = -9223372036854775808;
$this->max = 9223372036854775807;
break;
}
for ($i=0;$i < $lengch;$i++){
$this->array[$i] = 0;
}
}
function add ($vaule,$num){
if ($vaule >= $this->max || $vaule <= $this->min || !is_numeric($num) || $num < 0 || $num >= $this->lengch){
echo "Not valid vaule!\n";
return false;
}
$this->array[$num] = $vaule;
}
function ToNormalArray (){
return $this->array;
}
function get ($num){
if ($num >= $this->lengch || $num < 0){
echo "BAD ARRAY INDEX\n";
return false;
}
return $this->array[$num];
}
function GetLengch(){
return $this->lengch;
}
}
Обнаружил в исходниках одного из сайтов который разрабатывал. Предыдущий кодер действительно этим ползовался! Особенно умиляет метод ToNormalArray().
someone 25.12.2013 07:47 # +6
Длинча?
kegdan 25.12.2013 08:03 # −2
someone 25.12.2013 08:46 # 0
1024-- 25.12.2013 09:30 # +1
someone 25.12.2013 09:31 # +2
kegdan 25.12.2013 12:47 # +2
inkanus-gray 25.12.2013 15:38 # +2
Либо что-нибудь на балтийских языках. Если saule = солнце, то и vaule должно что-то означать...
Lure Of Chaos 28.12.2013 00:33 # 0
bormand 28.12.2013 05:34 # 0
Lure Of Chaos 28.12.2013 08:58 # 0
bormand 28.12.2013 09:34 # 0
kegdan 28.12.2013 10:07 # 0
1024-- 28.12.2013 10:49 # 0
Всё же, (new X).constructor === X даёт true, что наводит на некоторые мысли.
Да и в ECMA-262 словом "constructor" пользуются
4.2.1 Objects
ECMAScript does not use classes such as those in C++, Smalltalk, or Java. Instead objects may be created in various ways including via a literal notation or via constructors which create objects and then execute code that initialises all or part of them by assigning initial values to their properties. Each constructor is a function that has a property named "prototype" that is used to implement prototype-based inheritance and shared properties.
4.3 Terms and definitions
For the purposes of this document, the following terms and definitions apply.
<...>
4.3.4
constructor
function object that creates and initialises objects
bormand говорит по стандарту :)
roman-kashitsyn 28.12.2013 10:41 # 0
1024-- 28.12.2013 11:00 # +3
http://ideone.com/K5COSp
11.2.2 The new Operator; 13.2.2 [[Construct]]
roman-kashitsyn 28.12.2013 11:12 # +1
bormand 28.12.2013 11:34 # 0
1024-- 28.12.2013 11:44 # 0
Stertor 28.12.2013 11:46 # −2
1024-- 28.12.2013 11:53 # +3
Stertor 28.12.2013 11:54 # +1
kegdan 28.12.2013 11:53 # −2
Lure Of Chaos 28.12.2013 11:55 # +3
kegdan 28.12.2013 11:57 # 0
Lure Of Chaos 28.12.2013 11:59 # +1
kegdan 28.12.2013 12:02 # +1
Lure Of Chaos 28.12.2013 12:03 # +2
Stertor 28.12.2013 12:04 # +1
kegdan 28.12.2013 12:09 # 0
А как же первая поправка?
Stertor 28.12.2013 12:14 # +1