Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 20:43
    wontruefree synchronize #11682
  • 20:42
    wontruefree synchronize #11697
  • 20:04
    beta-ziliani milestoned #11719
  • 19:57
    beta-ziliani milestoned #11697
  • 19:53
    beta-ziliani milestoned #11690
  • 19:51
    beta-ziliani milestoned #11689
  • 19:49
    beta-ziliani milestoned #11684
  • 19:43
    beta-ziliani milestoned #11676
  • 19:40
    beta-ziliani review_requested #11591
  • 19:39
    beta-ziliani milestoned #11570
  • 19:35
    beta-ziliani review_requested #11207
  • 18:42
    beta-ziliani milestoned #11544
  • 18:34
    beta-ziliani milestoned #11533
  • 18:31
    beta-ziliani milestoned #11524
  • 18:27
    beta-ziliani milestoned #11476
  • 18:13
    beta-ziliani milestoned #11450
  • 18:12
    beta-ziliani labeled #11393
  • 18:10
    beta-ziliani synchronize #11207
  • 18:05
    beta-ziliani milestoned #11201
  • 17:57
    beta-ziliani reopened #11190
George Dietrich
@Blacksmoke16
can you not just do like
it "with one item" do
  layout.each_line do |a, b|
    a.should eq [1]
    b.should eq 1
  end
end
or something along those lines?
wayy more readable imo
Layout.new*
or whatever the type is
nanobowers
@nanobowers
Yeah, probably so... I've used rspec for some time and never seen even half of the stuff i've seen used in this code.
George Dietrich
@Blacksmoke16
Spec module is deff a lot more simplistic than rspec, IMO for the better most of the time
nanobowers
@nanobowers
Are 'named' globals available? Saw very little discussion in the documentation and the compiler complains when the long-name versions of builtin globals are used e.g. $0 vs $PROGRAM_NAME and $? vs $CHILD_STATUS
George Dietrich
@Blacksmoke16
crystal doesn't have global vars
at least that the user can define on their own. The only real global vars are defined via the compiler, which are like $~ and $1, $n representing regex matches
nanobowers
@nanobowers
Makes sense, will need to add that to my list of things to find the Ruby equivalent for - I think i've figured out $? equiv vias Process.run()
Thanks for all of the help/advice
YusufCakan
@YusufCakan
how to people normally debug the crystal compiler. Are there any instructions on how to do this.
Jonathan Silverman
@mixflame
confirmed amber redis websocket adapter patch is stable and works with multiple amber processes :D
+tests added+
From IRC (bridge bot)
@FromIRC
<postmodern> is there an Enumerable method that finds the last occurance based on a block?
<jhass[m]> mmh, I don't think so but could maybe concort something with with_index and max?
Quinton Miller
@HertzDevil
you cannot traverse backwards with an Enumerable, but there's rindex for Indexable
From IRC (bridge bot)
@FromIRC
<jhass[m]> has some yet unhandled edge cases around the only match being the first one or no match of course
Quinton Miller
@HertzDevil
From IRC (bridge bot)
@FromIRC
<jhass[m]> Indexable#rfind could use reverse_each and break I guess
From IRC (bridge bot)
@FromIRC
<postmodern> how do i specify a literal ASCII string? "\xff\xfe" is being interpreted as a unicode string with one character instead of two
Ali Naqvi
@naqvis
"\u{ff}\u{fe}" if two separate chars
From IRC (bridge bot)
@FromIRC
<postmodern> ah, weird syntax but that seems to work
<postmodern> ah but that defines a unicode string of four bytes. i need a two-byte string of 0xff and 0xfe
Ali Naqvi
@naqvis
"\xff\xfe" is actually two byte String
pp "\xff\xfe".to_slice # => Bytes[255, 254]
can you please describe, what are you getting? and what's your expected output?
From IRC (bridge bot)
@FromIRC
<postmodern> i think the problem is because my code is using String#chars which returns unicode characters
Ali Naqvi
@naqvis
but FF FE is a UTF16-LE BOM
From IRC (bridge bot)
@FromIRC
<postmodern> yeah, kind of wish Crystal had a way to forcibly defining an ASCII string, so you can contain non-UTF binary strings of random data that could be misinterpreted as UTF codepoints
Ali Naqvi
@naqvis

pp "\u{ff}\u{fe}".chars # => ['ÿ', 'þ']

this is correct representation

From IRC (bridge bot)
@FromIRC
<postmodern> bytes shows extra unicode stuff in there [195, 191, 195, 190]
George Dietrich
@Blacksmoke16
are they multibyte chars?
From IRC (bridge bot)
@FromIRC
<postmodern> they shouldn't be, but i guess they are being interpreted as such
Ali Naqvi
@naqvis
since String is UTF-8 but you are dealing with UTF-16
so you should be invoking "\u{ff}\u{fe}".to_utf16 to get the correct byte representation
From IRC (bridge bot)
@FromIRC
<postmodern> crystal's utf8-by-default Strings are making it hard for me to define a String of garbage ASCII data
Ali Naqvi
@naqvis
for encoding other than UTF-8 you should be using stream instead of String
From IRC (bridge bot)
@FromIRC
<postmodern> ah ha, thanks
From IRC (bridge bot)
@FromIRC
<postmodern> curious why String.new(Bytes[0xff, 0xfe]).chars.map(&.ord) returns [65533, 65533]
<postmodern> ah ha, i probably want to check String#valid_encoding? and check String#chars otherwise check String#bytes.
Ali Naqvi
@naqvis
its because that's not valid UTF-8
String.from_utf16("\u{ff}\u{fe}".to_utf16).chars.map(&.ord) # => [255, 254]
From IRC (bridge bot)
@FromIRC
<postmodern> well got specs passing. good enough for now.
<jhass[m]> I still wish we kept String at enforced valid UTF-8 only and instead developed better tooling around Bytes