0

I know I saw this => double arrow symbol in python programming but I cannot remember in which context, please advise if possible.

P.S. I only found -> but not => (not sure if it would be the same or there is a difference between them!

Thanks in advance

LupaSeal
  • 1
  • 1
  • 5
    I don't think it means anything. Maybe you mean `>=`, which is "greater than or equal" – Barmar Sep 15 '22 at 20:20
  • There is also <= Meaning Less than or equal to. – Will Metcher Sep 15 '22 at 20:21
  • `=>` and `->` in python are both invalid syntax; `<-` is interpreted simply as less than and then a negative symbol, so e.g. `1 <- 4` means `one less than negative four` which gets evaluated as `False`. maybe you're thinking of [`R`](https://stackoverflow.com/questions/1741820/what-are-the-differences-between-and-assignment-operators)? – Michael Delgado Sep 15 '22 at 20:38
  • 1
    @MichaelDelgado `->` is not an operator, but it's not invalid: it's use to annotate the return value of a function. – chepner Sep 15 '22 at 20:41
  • ok that's fair - if you're talking about type hints. it's invalid syntax if used as an operator but not in a function definition. that might be what the OP is asking about? – Michael Delgado Sep 15 '22 at 20:41
  • A function definition *is* a statement. – chepner Sep 15 '22 at 20:42
  • You can use the tokenizer to see that `=>` is recognized as two separate tokens, `=` and `>`. `python -m tokenize <<< "=>"`. By contrast, `python -m tokenize <<< "->"` recognizes a single token `->`. – chepner Sep 15 '22 at 20:43
  • ok ok point taken. you're right - I think you may have the answer the OP is looking for – Michael Delgado Sep 15 '22 at 20:44
  • @LupaSeal see [this question on type hints](https://stackoverflow.com/questions/5336320/how-to-know-function-return-type-and-argument-types) - is this what you're asking about? – Michael Delgado Sep 15 '22 at 20:54

1 Answers1

0

I have searched and apparently something was stuck in my mind, but apparently not related to python.

In PHP This is referred to as the double arrow operator. It is an assignment operator used in the creation of associative arrays, but we do not have something like this in python.

example:

<?php
$person = array(
    "firstName" => "John",
    "lastName" => "Doe",
    "age" => 28,
    "gender" => "Male",
    "email" => "johndoe@gmail.com",
    "city" => "Germany"
);
?>
LupaSeal
  • 1
  • 1