Re: what is the meaning



Thomas Mlynarczyk wrote:

sam wrote:
What is the meaning of this operator:-
=>

Assignment - used in arrays?

Hm. But why the need for a special operator here? Wouldn't
a simple = have done the job just as well?

Yes, but you'd have to write it differently.

Consider this simple example:

$someArray = array('field1' => 1, 'field2' => 'two');

If it equivalent to:

$someArray = array();
$someArray['field1'] = 1;
$someArray['field2'] = 'two';

Moreover, the second option might trigger an E_NOTICE, since
you would be trying to assign a value to a not-yet-defined member
of the array...

Cheers,
NC

.



Relevant Pages

  • Re: why cannot assign to function call
    ... understand how assignments work in these languages, ... as in Python, Java, REALbasic, .NET, etc. ... Arrays are the only datatype in C that don't use ... Python's assignment semantics, and further appear ...
    (comp.lang.python)
  • Re: malloc creates seg faults?
    ... > for duplicating arrays of some objects. ... > the required memory, ... retval does not point to Product here as there malloc returns raw memory. ... As *p is not a Product this assignment is meaningless. ...
    (comp.lang.cpp)
  • Re: Unknown size
    ... For arrays of size 3 or so, it must be a killer on any particular assignment, but how about globally for a whole program? ... We did have customers who complained about their programs getting slower due to this check, so it seems to be real, especially when the assignment is in a loop. ... User communities for Intel Software Development Products ...
    (comp.lang.fortran)
  • Re: why cannot assign to function call
    ... other types (disputedly except arrays) are. ... One can then use that pointer to manually effect ... to wrap your brain around than that of other languages. ... and read wild claims that Python's assignment and parameter-passing ...
    (comp.lang.python)
  • Re: setting object properties for object array in 2008a obj model
    ... The class has a single property, Tag, and set.Tag & ... For arrays, the getter works fine. ... My problem is assignment. ...
    (comp.soft-sys.matlab)