Ruby Basics: Symbols vs Strings

Поделиться
HTML-код
  • Опубликовано: 18 янв 2025

Комментарии • 40

  • @joey2545
    @joey2545 6 лет назад +12

    This is a fantastic explanation of symbols in Ruby. I love the detail and technical explanation when it comes to storing objects in memory with Ruby yet the elegant simplicity of how you phrase and explain these concepts step by step. I've been working as a junior RoR developer for a few months and this video cleared up a lot of misconceptions for me. Thank you!

  • @ondrejsvoboda6207
    @ondrejsvoboda6207 2 года назад +3

    Underrated content, finally an easily understandable explanation

  • @ayuthmang
    @ayuthmang Год назад +1

    I love you explanination with details and context. I come from other programming languages and stugling syntax in rails for a long time. This video make everything pretty clear.

    • @GorailsTV
      @GorailsTV  Год назад +1

      Glad we can help! Anything else you've been struggling on with Ruby?

    • @ayuthmang
      @ayuthmang Год назад

      For me ruby itself is straightforward unless you step into rails world. Things get weird and confusing.

  • @RR-et6zp
    @RR-et6zp Год назад +3

    Great explanation. You're single handedly carrying the Rails community on your back I swear

  • @jacinyan3893
    @jacinyan3893 4 года назад +2

    Good gracious, I've been confused about the use of symbols in Rails since started learning it. Thank you so much!!

  • @yp5387
    @yp5387 Год назад +1

    It suddenly started to make sense when you did a demo with an object id property.

  • @jackriminton7959
    @jackriminton7959 4 года назад +2

    Really great explanation, please do more of these!

  • @jakewoodruff13
    @jakewoodruff13 Год назад +1

    Awesome tips! Thanks!

  • @ClaudineyPerbony
    @ClaudineyPerbony 5 лет назад

    Very clear explanation. Best ROR channel

  • @faizan2006
    @faizan2006 4 года назад +1

    Nice explanation and easy to understand.. Thanks Chris..

  • @sherriffs2554
    @sherriffs2554 5 лет назад +2

    Also worth noting with symbol comparison ruby only needs to compare object_id's. With strings ruby has to compare the actual data.

  • @kaysong3800
    @kaysong3800 2 года назад +1

    awesome explaination, thank you so much!

  • @FNMonsters
    @FNMonsters 2 года назад +1

    Amazing tutorial. Thank you very much!

  • @Rod_Tolledo
    @Rod_Tolledo 4 года назад +1

    Great explanation, thank you!

  • @Ranterd
    @Ranterd 2 года назад

    Excellent explanation of ruby's features. I like your condensed deep dives! i was unaware of the implied optional inclusion of a hash as the last argument of any method call. Also is this more compact representation of hashes good for multi-dimemsional hashes? (Ex: see fortran arrays)

  • @davidlytikainen5815
    @davidlytikainen5815 2 года назад +1

    super helpful. thanks man

    • @GorailsTV
      @GorailsTV  2 года назад

      Let me know if there are other concepts you'd like a video on!

  • @lorieldesamito3998
    @lorieldesamito3998 2 года назад +1

    thanks

  • @karoskibinska4059
    @karoskibinska4059 5 лет назад

    Very clear explanation, thank you!

  • @默-c1r
    @默-c1r Год назад

    thank you! very helpful

  • @Lyrik-Klinge
    @Lyrik-Klinge 3 года назад

    Very nice explanations!
    May I ask you what editor you use?

    • @GorailsTV
      @GorailsTV  3 года назад

      MacVim + github.com/excid3/dotfiles

    • @Lyrik-Klinge
      @Lyrik-Klinge 3 года назад

      @@GorailsTV Thank you:-)

  • @RsZ789
    @RsZ789 5 лет назад

    Thank you, I now understand symbols. Great job!

  • @cutliss
    @cutliss 5 лет назад

    what's that intro soundtrack? I heard it once in a game but struggled to find it

    • @GorailsTV
      @GorailsTV  5 лет назад

      It's a track I bought on audiojungle. Forget the name.

  • @pavlo-vasylkivskyi
    @pavlo-vasylkivskyi 4 года назад +1

    Thank you Chris. Is it still relevant to learn ROR in 2021?

    • @GorailsTV
      @GorailsTV  4 года назад +1

      Absolutely. In fact some really amazing new stuff just came out and the community is growing a lot latrly

  • @paulryan6269
    @paulryan6269 4 года назад +1

    Awesome

  • @dc366
    @dc366 5 лет назад

    Hard to see this video on mobile

  • @elisson357
    @elisson357 5 лет назад

    Thanks for Sharing This.

  • @AlexanderShelestov
    @AlexanderShelestov 4 года назад

    Use symbols actually don't make sense anymore, cause every Ruby string is going to be frozen in memory by default.
    Today you can do it using .freeze method or add this comment line at the top of any ruby file:
    # frozen_string_literal

    • @GorailsTV
      @GorailsTV  4 года назад +3

      Yeah the goal is to make static strings closer in performance to symbols. I'm not sure if they are quite as performance as symbols, so I'd still recommend using them over strings. Plus symbols convey that it's something reusable like a hash key, which helps differentiate your code better at a glance.

    • @AlexanderShelestov
      @AlexanderShelestov 4 года назад

      @@GorailsTV I've benchmarked use the different types of keys in a hash. The results:
      Symbol: 9.550638 0.006868 9.557506 ( 9.571867)
      String: 15.660584 0.006830 15.667414 ( 15.678722)
      Frozen String: 10.984252 0.004975 10.989227 ( 10.993361)
      So the frozen string is performance enough to be used in hashes :)

    • @AlexanderShelestov
      @AlexanderShelestov 4 года назад

      But of course, it's still handier to use ruby symbols for this.

    • @GorailsTV
      @GorailsTV  4 года назад +1

      That doesn't take into account garbage collection and things right? I can't remember if it handled them differently. Either way, I'd still recommend symbols for keys that never change and strings only when you need dynamic keys.

  • @Randych
    @Randych Год назад

    You tried but it didn't help.