user-documentation icon indicating copy to clipboard operation
user-documentation copied to clipboard

Added examples for Dict\fill_keys and Dict\from_values

Open YAXINLEI opened this issue 3 years ago • 1 comments

Screen Shot 2022-10-13 at 5 40 52 PM Screen Shot 2022-10-13 at 5 40 17 PM

Passed all tests by running ./vendor/bin/hacktest tests/: Summary: 5102 test(s), 5102 passed, 0 failed, 0 skipped, 0 error(s).

YAXINLEI avatar Oct 14 '22 00:10 YAXINLEI

Would you like to replace print_r with an HSL function?

Atry avatar Oct 14 '22 02:10 Atry

Would you like to replace print_r with an HSL function?

Hey Atry, thanks a lot. I'd love to, but I wasn't able to find an appropriate HSL function for printing dictionaries. Echo also doesn't work. Would it be possible to help me with this. Many many thanks!

YAXINLEI avatar Oct 16 '22 04:10 YAXINLEI

https://docs.hhvm.com/hsl/reference/function/HH.Lib.IO.request_output/

Yaxin Lei @.***>于2022年10月15日 周六下午9:37写道:

Would you like to replace print_r with an HSL function?

Hey Astry, thanks a lot. I'd love to, but I wasn't able to find an appropriate HSL function for printing dictionaries. Echo also doesn't work. Would it be possible to help me with this. Many many thanks!

— Reply to this email directly, view it on GitHub https://github.com/hhvm/user-documentation/pull/1300#issuecomment-1279889922, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAES3OVKTIRVW4JIGI3WHJDWDOA65ANCNFSM6AAAAAAREY2Z3A . You are receiving this because you commented.Message ID: @.***>

Atry avatar Oct 16 '22 04:10 Atry

Thank you so much for your help! Would the following be the right way to use it as IO\request_output also doesn't have too many documentations.

$values = vec[1, 2, 3, 4];
$dict = Dict\from_values($values, $x ==> $x + 1);
IO\request_output($dict);

I was trying to learn from previous examples and I found both Dict.select_keys and Dict.groupby were using print_r in the existing documentation: https://github.com/hhvm/user-documentation/blob/main/api-examples/function.HH.Lib.Dict.select_keys.md

YAXINLEI avatar Oct 16 '22 05:10 YAXINLEI

https://docs.hhvm.com/hsl/reference/function/HH.Lib.IO.request_output/ Yaxin Lei @.>于2022年10月15日 周六下午9:37写道: Would you like to replace print_r with an HSL function? Hey Astry, thanks a lot. I'd love to, but I wasn't able to find an appropriate HSL function for printing dictionaries. Echo also doesn't work. Would it be possible to help me with this. Many many thanks! — Reply to this email directly, view it on GitHub <#1300 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAES3OVKTIRVW4JIGI3WHJDWDOA65ANCNFSM6AAAAAAREY2Z3A . You are receiving this because you commented Screen Shot 2022-10-16 at 1 05 55 AM .Message ID: @.>

All tests passed locally, and the webpage also looks fine.

https://docs.hhvm.com/hsl/reference/function/HH.Lib.IO.request_output/ Yaxin Lei @.>于2022年10月15日 周六下午9:37写道: Would you like to replace print_r with an HSL function? Hey Astry, thanks a lot. I'd love to, but I wasn't able to find an appropriate HSL function for printing dictionaries. Echo also doesn't work. Would it be possible to help me with this. Many many thanks! — Reply to this email directly, view it on GitHub <#1300 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAES3OVKTIRVW4JIGI3WHJDWDOA65ANCNFSM6AAAAAAREY2Z3A . You are receiving this because you commented.Message ID: @.>

All local tests and builds looks fine.

https://docs.hhvm.com/hsl/reference/function/HH.Lib.IO.request_output/ Yaxin Lei @.>于2022年10月15日 周六下午9:37写道: Would you like to replace print_r with an HSL function? Hey Astry, thanks a lot. I'd love to, but I wasn't able to find an appropriate HSL function for printing dictionaries. Echo also doesn't work. Would it be possible to help me with this. Many many thanks! — Reply to this email directly, view it on GitHub <#1300 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAES3OVKTIRVW4JIGI3WHJDWDOA65ANCNFSM6AAAAAAREY2Z3A . You are receiving this because you commented.Message ID: @.>

When I switched to request_output, and ran the following in the vscode debugger, nothing was given as output. And when I ran build, and looked at the website in through the server, it looked like the below. It would be awesome if you can provide some help, many thanks! Screen Shot 2022-10-16 at 1 11 20 AM Screen Shot 2022-10-16 at 1 15 06 AM

YAXINLEI avatar Oct 16 '22 05:10 YAXINLEI

See https://docs.hhvm.com/hack/getting-started/input-and-output for basic usage of request_output.

Atry avatar Oct 17 '22 16:10 Atry