0

In Hack, what is happening here and what does it mean? How do you read it?

 $foobar = $foo?->bar();
solimant
  • 591
  • 7
  • 14
  • 1
    That actually isn't valid syntax – John Conde Sep 23 '16 at 00:53
  • @JohnConde, do you recognize this as Hack (hacklang.org)? I'm new to both, so I might be mistaken about the language. But I'm not mistaken about the syntax. – solimant Sep 23 '16 at 06:21
  • @JohnConde this is not a duplicate of the linked question. –  Sep 23 '16 at 09:01
  • 2
    @bigT since this has been incorrectly closed as a duplicate, I can't submit this as an answer. The operator is the [null safe](https://docs.hhvm.com/hack/operators/null-safe) operator. If `$foo` is `null`, then `null` is returned. Otherwise, it acts as the normal object access operator. –  Sep 23 '16 at 09:02
  • @simon_w This was *correctly* marked as a dupe when it was closed because the OP marked this as a PHP question. All PHP questions relation to symbols are dupes of the question above. Since the question has been clarified this can be reopened. – John Conde Sep 23 '16 at 10:49
  • @JohnConde, thanks. Could you unmark it as dupe? – solimant Sep 23 '16 at 17:08
  • @simon_w, you are right, this is Hack indeed. Are you able to submit answer now? Please do, and I'll mark it as accepted. – solimant Sep 23 '16 at 17:09
  • I voted to reopen but we still need two votes for it to reopen. I don't know why I couldn't do so automatically. I guess they changed something that prevents that now. – John Conde Sep 23 '16 at 17:34
  • Strange.. It says on your PHP badge "Users with the PHP badge can single-handedly close PHP questions as duplicates and reopen them as needed." – solimant Sep 23 '16 at 18:07

0 Answers0